Main > Forum > 1C:Enterprise Platform > 1C:Integration > How to get e-mail text?

Forum

Search UsersRules
How to get e-mail text?
#1
Active user
Points:: 0
Joined:: Sep 18, 2012

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;

Profile
#2
Guest
Points::
Joined::

Hello, Kris!

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

Hope, this helps.

Profile
#3
Active user
Points:: 0
Joined:: Sep 18, 2012

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;

Profile
#4
Guest
Points::
Joined::

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.

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.