Receive emails via livecode

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
FireWorx
Posts: 362
Joined: Wed Sep 07, 2011 9:39 pm

Receive emails via livecode

Post by FireWorx » Mon Mar 11, 2013 5:41 pm

So Ive searched google, the forum and the IOS release notes.

My question is is there a way to monitor e-mails or text messages that are incoming and if it is from a specific user open the email or text and mine some data from it? I see the ability to compose and send text and emails but not receive them in this fashion. Perhaps this is just asking to much?
Dave

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Receive emails via livecode

Post by shaosean » Tue Mar 12, 2013 6:09 am

You need a POP3 library to access emails on the server.. I would recommend one that can do the TOP command so you just grab the headers to look for the messages you want to retrieve completely from the server.. The POP3 part is easy, decoding of the email messages is the pain (good old MIME)..

LC4iOS
Posts: 88
Joined: Tue Dec 03, 2013 8:15 pm

Re: Receive emails via livecode

Post by LC4iOS » Fri Dec 13, 2013 9:48 pm

I'd like to pursue this further.
I'm looking thru the TROZ libraries now.
Has anyone got a hyperlink for further research?

Wow!
Upon further research into this library,
looks like everything I'm looking for is already there.
Release in 2010 and seems like no further updates were necessary.
Very cool
Thanks to RunRev.
Thanks to LiveCode forum members.

LiveCode v5.5.5 - iOS Android Mac Windows - 6.5 Community
27" 2012 iMac i5, MacBook Pro, MacBook Air, iPhone 5, iPhone 4
xCode 5.0.2 - iOS7 - OS X Mavericks
Paid Apple iOS Developer Program Member

LC4iOS
Posts: 88
Joined: Tue Dec 03, 2013 8:15 pm

Re: Receive emails via livecode

Post by LC4iOS » Wed Dec 18, 2013 8:02 am

Just sharing ...

Added a get DateAndTime routine - this worked for two difference email servers
and fixed the Clear script to include enabling Read emails button

Error: Sorry, the board attachment quota has been reached.

At the moment it seems that out of 19 emails only 12 are getting saved to text files.
I'm sure they are 7 duplicates.
Not sure if we care.
I'll probably change the file name to reflect the DateAndTime received.
Thanks to RunRev.
Thanks to LiveCode forum members.

LiveCode v5.5.5 - iOS Android Mac Windows - 6.5 Community
27" 2012 iMac i5, MacBook Pro, MacBook Air, iPhone 5, iPhone 4
xCode 5.0.2 - iOS7 - OS X Mavericks
Paid Apple iOS Developer Program Member

LC4iOS
Posts: 88
Joined: Tue Dec 03, 2013 8:15 pm

Re: Receive emails via livecode

Post by LC4iOS » Fri Dec 20, 2013 9:08 am

Is there a way to uniquely identify emails from the headers?
I thought Date Time From Subject.

Is there a UID somewhere in the email headers?

Found it.
Message-ID: 20050329231145.62086.mail@mail.emailprovider.com
A unique number assigned by mail.emailprovider.com to identify the message.

Its where I'm getting the Date Time
yyyymmddhhmmss.etc
Last edited by LC4iOS on Fri Dec 20, 2013 10:16 pm, edited 1 time in total.
Thanks to RunRev.
Thanks to LiveCode forum members.

LiveCode v5.5.5 - iOS Android Mac Windows - 6.5 Community
27" 2012 iMac i5, MacBook Pro, MacBook Air, iPhone 5, iPhone 4
xCode 5.0.2 - iOS7 - OS X Mavericks
Paid Apple iOS Developer Program Member

SparkOut
Posts: 2943
Joined: Sun Sep 23, 2007 4:58 pm

Re: Receive emails via livecode

Post by SparkOut » Fri Dec 20, 2013 10:23 am

Careful with the date extraction there - the message ID is not a standard format, afaik, it is just a string that identifies individual messages and I believe the sender's service can generate whatever string it chooses by its own rules. Messages from sources other than your test may not have the same ID generator.
That example header - did you get that from a real message? Was it really sent in 2005?

LC4iOS
Posts: 88
Joined: Tue Dec 03, 2013 8:15 pm

Re: Receive emails via livecode

Post by LC4iOS » Fri Dec 20, 2013 10:20 pm

Thanks SparkOut.

I was sure to mention it worked on my two providers so far.

l'll sort the date time stamp out when the situation arrises.
I do see another verbose date with GMT offset.
I'll have to see if there is an example of coverting it to sql date n time here on livecode forums.

That example header is just an example.

Still can't upload my projects.
Thanks to RunRev.
Thanks to LiveCode forum members.

LiveCode v5.5.5 - iOS Android Mac Windows - 6.5 Community
27" 2012 iMac i5, MacBook Pro, MacBook Air, iPhone 5, iPhone 4
xCode 5.0.2 - iOS7 - OS X Mavericks
Paid Apple iOS Developer Program Member

LC4iOS
Posts: 88
Joined: Tue Dec 03, 2013 8:15 pm

Re: Receive emails via livecode

Post by LC4iOS » Sat Dec 21, 2013 3:09 am

LiveCode makes everything look easy.
But user contribution make LiveCode ROCK!

Code: Select all

convert "Sat, 21 Dec 2013 12:54:29 +1100" from internet date to short date and short time
   
   answer it
   
   convert "Sat, 21 Dec 2013 12:54:29 +1100" from internet date to dateItems
   
   answer it
   
   answer the internet date
   
   convert the internet date from internet date to dateItems
   
   answer it
Thanks to RunRev.
Thanks to LiveCode forum members.

LiveCode v5.5.5 - iOS Android Mac Windows - 6.5 Community
27" 2012 iMac i5, MacBook Pro, MacBook Air, iPhone 5, iPhone 4
xCode 5.0.2 - iOS7 - OS X Mavericks
Paid Apple iOS Developer Program Member

LC4iOS
Posts: 88
Joined: Tue Dec 03, 2013 8:15 pm

Re: Receive emails via livecode

Post by LC4iOS » Sat Dec 21, 2013 11:08 pm

Some of the email subjects are returning strange content:

=?windows-1252?Q?Academics_Save_50%_on_Valentina_Studio_Pro?=

Its easy enough to clean up but I was just wondering what this encoding is?

All messages are mime type v1.
Even the ones without this strange content.
Thanks to RunRev.
Thanks to LiveCode forum members.

LiveCode v5.5.5 - iOS Android Mac Windows - 6.5 Community
27" 2012 iMac i5, MacBook Pro, MacBook Air, iPhone 5, iPhone 4
xCode 5.0.2 - iOS7 - OS X Mavericks
Paid Apple iOS Developer Program Member

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10044
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Receive emails via livecode

Post by FourthWorld » Sat Dec 21, 2013 11:29 pm

Just another example of Microsoft not adopting common standards - apparently they felt ISO 8859-1 wasn't good enough for them:
http://en.wikipedia.org/wiki/Windows-1252
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply