How to get e-mail text?

1C:Enterprise platform integration capabilities and techniques

#1
People who like this:0Yes/0No
Active user
Rating: 2
Joined: Sep 18, 2012
Company:

Hello,
I need to check e-mails and get their texts (messages). Below is my script. How to get e-mail text? I use 8.1 platform.
Thank you in advance.
Kris

Code
   
Profile = New InternetMailProfile;
Profile.User = User;
Profile.Password = Pass;
Profile...
      
   MailBox = New InternetMail;
   MailBox.Logon(Profile);
   Mails = MailBox.Get(true);
   
   If Mails.Count() > 0 Then
      
        For each Mail in Mails Do
      
//here I need to get text of mail and process it line by line, how to do it?       

        EndDo;
   EndIf;

 
#2
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

Hello, Kris!

Try using the Email operations subsystem of 1C:Subsystems Library.

Hope, this helps.

 
#3
People who like this:0Yes/0No
Active user
Rating: 2
Joined: Sep 18, 2012
Company:

Thank you Timofey for your help but I solved the problem this way:

Code
   MailBox = New InternetMail;
   MailBox.Logon(Profile);
   Mails = MailBox.Get(true);
   lp = 0;
   If Mails.Count() > 0 Then
   For each Mail in Mails Do
            If Mail.Texts.Count() > 0 Then
            For each Text in Mail.Texts Do
                      lp=lp+1;
                      Data = Text.Data;            
                      Data.Write(SaveTempPath + "FileName"+String(lp)+".txt");

                      TextReader = New TextReader(SaveTempPath + "FileName"+String(lp)+".txt");
                      Str = TextReader.ReadLine();
                      While Str <> Undefined Do
                      Message(Str);
                      Str = TextReader.ReadLine();
                      EndDo;
            EndDo;
            EndIf;
   EndDo;
   EndIf;

 
#4
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

Thank you for sharing, Kris!

By the way, there is no need in those conditions:

Code
If Mails.Count() > 0 Then

and
Code
If Mail.Texts.Count() > 0 Then

Because if an array or a collection is empty, For Each traversal will be skipped.

 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.