Send an Email

The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Active user
Rating: 5
Joined: Jun 4, 2013
Company:

Tell me how to send an email from 1C?

 
#2
People who like this:0Yes/0No
Interested
Rating: 27
Joined: Apr 5, 2012
Company: 1TÇ Şirketi - Merv Bilgi İşlem Otomasyonu Yazılım Ltd. Şti.

You may try this code example:

Code
   MailProfil = New InternetMailProfile; 
   
   MailProfil.SMTPServerAddress = "mail.gmail.com"; 
   MailProfil.SMTPAuthentication = SMTPAuthenticationMode.Default; 
   //MailProfil.SMTPPort = 587; 
   
   MailProfil.Timeout = 180; 
   
   //MailProfil.Password = "*********"; 
   MailProfil.SMTPPassword = "*********"; 
   
   //MailProfil.User = "*********@gmail.com"; 
   MailProfil.SMTPUser = "*********@gmail.com"; 
   
   //MailProfil.POP3ServerAddress = "mail.gmail.com"; 
   //MailProfil.POP3Port = 110; 
   
   GönderMesajı = New InternetMailMessage; 
   GönderMesajı.To.Add("*********@gmail.com"); 
   GönderMesajı.From.Address = "*********@gmail.com"; 
   GönderMesajı.Subject = "New message"; 
   GönderMesajı.Texts.Add("Context of messsage"); 
   
   Posta = New InternetMail; 
   Posta.Logon(MailProfil); 
   Posta.Send(GönderMesajı); 
   Posta.Logoff();

 
#3
People who like this:0Yes/0No
Administrator
1C:Professional
Rating: 8
Joined: Jun 25, 2013
Company: 1C Company

You can also see examples in Subsystems library. It includes the EmailOperations standard subsystem.

1C Company support team
 
#4
People who like this:0Yes/0No
Active user
Rating: 5
Joined: Jun 4, 2013
Company:

Thanks a lot I'll try those methods :)

 
#5
People who like this:0Yes/0No
Interested
Rating: 11
Joined: Nov 10, 2011
Company: 1A Software e.U

Is it possible to send per email attachments as well? Some users would like to send invoices to their customers.

 
#6
People who like this:0Yes/0No
Administrator
1C:Professional
Rating: 8
Joined: Jun 25, 2013
Company: 1C Company

Of course you can send emails with attachments by using Attachments property of InternetMailMessage

1C Company support team
 
#7
People who like this:0Yes/0No
Active user
Rating: 5
Joined: Jun 4, 2013
Company:

Hi .... Sorry for responding after a long time, but today i tried the script above but unfortunately it failed, i think there is something wrong in the SMTPaddress ... look at what i did :  

Code
  MailProfil = New InternetMailProfile; 
  MailProfil.SMTPServerAddress = "mail.gmail.com"; 
  MailProfil.SMTPAuthentication = SMTPAuthenticationMode.Default; 
  MailProfil.Timeout = 60; 
  MailProfil.SMTPPassword = "########";  // here i put the sender password
  MailProfil.SMTPUser = "mohammad.maleh@gmail.com";// here i put the sender Email

  send = New InternetMailMessage; 
  send.To.Add("mohammad.maleh@gmail.com"); // here i put the receiver email  
  send.From.Address = "mohammad.maleh@gmail.com"; 
  send.Subject = "New message"; 
  send.Texts.Add("Context of messsage"); 
   
  mail = New InternetMail; 
  mail.Logon(MailProfil); 
  mail.Send(send); 
  mail.Logoff();

When i ran it ... it gave me this error :

{Catalog.Catalog1.Form.ListForm.Form(21)}: Error calling context method (Logon)
  mail.Logon(MailProfil);
because:
Error writing server address (11001)



could anyone help me please ... and thanks in advance :)

 
#8
People who like this:0Yes/0No
Active user
Rating: 5
Joined: Jun 4, 2013
Company:

I forgot to mention that I tried this address with its port too  ... but it failed also !!

Code
MailProfil.SMTPServerAddress = "smtp.gmail.com"; 
MailProfil.SMTPPort="465"  ;

 
#9
People who like this:1Yes/0No
Administrator
1C:Professional
Rating: 8
Joined: Jun 25, 2013
Company: 1C Company

With the same error?

By the way, 465 port requires SSL to be used. Try to set it obviously.

Code
MailProfil.SMTPUseSSL = True;

1C Company support team
 
#10
People who like this:0Yes/0No
Just came
Rating: 0
Joined: Oct 8, 2012
Company: SPD Shcherbakov

The fact that Sergey Polikarpov wrote works if you are using a version of the 1c 8.3
Also, you need to remove the line,

Code
MailProfil.SMTPAuthentication = SMTPAuthenticationMode.Default; 

because it is necessary for 8.2
And 8.2 can not work with SSL

Edited: Dmitry Shcherbakov - Jul 18, 2013 03:47 AM
 
#11
People who like this:0Yes/0No
Just came
Rating: 0
Joined: Oct 8, 2012
Company: SPD Shcherbakov

You also need to check the configuration parameter "Compatibility mode". It should be set not less than "Version 8.3.1"

 
#12
People who like this:0Yes/0No
Active user
Rating: 5
Joined: Jun 4, 2013
Company:

thanks for helping.

no not the same error, it gives me Read operation timed out.

then when i entered the command above, the compiler couldn't find the SMTPUseSSL  object  


I tried the other port "587" ... then it give me another error which is :

catalog1.Form.ListForm.Form(24)}: Error calling context method (Send)
  mail.Send(send);
because:
The server requires authentication (SMTP error code 530, 5.7.0 Must issue a STARTTLS command first. l42sm18156009eeo.14 - gsmtp)

sorry for questioning a lot

 
#13
People who like this:0Yes/0No
Active user
Rating: 5
Joined: Jun 4, 2013
Company:

Dmitry Shcherbakov,
My version is 8.2 .... I'll install 8.3 then i'll try :)

 
#14
People who like this:0Yes/0No
Active user
Rating: 5
Joined: Jun 4, 2013
Company:

I can only find  1c : thin client 8.3 there is no enterprise!! ..... in thin client there is no designer !! ... what should I do in that case ?!!!

 
#15
People who like this:0Yes/0No
Just came
Rating: 0
Joined: Oct 8, 2012
Company: SPD Shcherbakov

Maybe you need to buy a license.
Or use "1C:Enterprise Platform 8 Training Version" for editing configuration

Edited: Dmitry Shcherbakov - Jul 18, 2013 05:42 AM
 
#16
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

The 1C:Enterprise 8.3 training version is now available in Downloads section.

 
#17
People who like this:0Yes/0No
Active user
Rating: 5
Joined: Jun 4, 2013
Company:

Hi ... I've made a software that sends emails when a form is closed ... but the form freezes before closing for 5-6 seconds while sending ... and that bothers the users ... is there any way to make it work quicker ?!!
and thanks in advance

 
#18
People who like this:0Yes/0No
Active user
Rating: 7
Joined: Sep 26, 2012
Company: individual

I do it by saving message and other information of email to Catalog (or another storage of 1C), and then send not processings elements by Scheduled jobs

 
#19
People who like this:0Yes/0No
Administrator
1C:Professional
Rating: 8
Joined: Jun 25, 2013
Company: 1C Company

mohammad maleh,
Here is a post that can help you establish connection between a 1C application and Gmail

1C Company support team
 
#20
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Sep 5, 2014
Company:

Hi Sergey,

I have read code in Subsystem Library 2.0 but I could not find Listing 3  GenerateInternetProfile function in EmailAccounts catalogs that you posted above. Pls help me to understand.

Thanks

Edited: Huong Tram - Jan 08, 2015 07:49 AM
 
#21
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

Hello, Huong Tram!

Try an example that is attached to this post in Creating HTML email templates using TextDocument topic.

 
#22
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Sep 5, 2014
Company:

Hi Timofey,
I understand a bout it. Thanks you so much.

 
#23
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Dec 19, 2022
Company:

Hi everyone, Can someone show me how to read emails. Thank you

 
#24
People who like this:0Yes/0No
Administrator
Rating: 18
Joined: Oct 3, 2019
Company:

Hello Bảo Vũ Bá,

try the following code:

Code
Function ReadEmails()
   
   MailProfile = New InternetMailProfile;
   
   MailProfile.IMAPServerAddress    = "imap.server.com";
   MailProfile.IMAPPort       = 993;
   MailProfile.IMAPUser       = "username";
   MailProfile.IMAPPassword    = "password";   
   
   Mail = New InternetMail;
   Mail.Logon(MailProfile, InternetMailProtocol.IMAP);
    
    
   structureSelectionOptions = New Structure;
   structureSelectionOptions.Insert("Seen", False);
   
   headers = Mail.GetHeaders(structureSelectionOptions);
   
   If headers.Count() > 0 Then
      
      arrayMessages = New Array;
           arrayMessages = Mail.Get(False, headers, True);
      
      For i = 0 По arrayMessages.Count() - 1 Do 
         
         
      EndDo;
      
   EndIf;   
   
EndFunction

 
#25
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Dec 19, 2022
Company:

Thanks Aleksandr Biryukov, I read one of your posts(https://1c-dn.com/blog/work-with-http-services-in-1c-part-2-post-method/) and I am having a problem and would like your help. Now, I have a task API. I have to create POST method to get data from web page size. do you have any suggestions for me, or a document that helps me do that. Thank you so much.

 
#26
People who like this:0Yes/0No
Administrator
Rating: 18
Joined: Oct 3, 2019
Company:

Dear Bảo Vũ Bá,

of course I'll be happy to help you. Just ask you to create a new topic with your question, so as not to clog this topic.

P.S.
Did you understand how to read emails?

 
#27
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Dec 19, 2022
Company:

I understood how to read email. Thank you, Aleksandr Biryukov

Edited: Bảo Vũ Bá - Dec 21, 2022 03:41 PM
 
Subscribe
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.