Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise – Business applications platform > Send an Email

Forum

Search UsersRules
Send an Email
#1
Active user
Points:: 0
Joined:: Jun 4, 2013

Tell me how to send an email from 1C?

Profile
#2
Interested
Points:: 0
Joined:: Apr 5, 2012

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();

Profile
#3
Active user
Points:: 0
Joined:: Jun 25, 2013

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

Profile
#4
Active user
Points:: 0
Joined:: Jun 4, 2013

Thanks a lot I'll try those methods :)

Profile
#5
Interested
Points:: 0
Joined:: Nov 10, 2011

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

Profile
#6
Active user
Points:: 0
Joined:: Jun 25, 2013

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

Profile
#7
Active user
Points:: 0
Joined:: Jun 4, 2013

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 :)

Profile
#8
Active user
Points:: 0
Joined:: Jun 4, 2013

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"  ;

Profile
#9
Active user
Points:: 0
Joined:: Jun 25, 2013

With the same error?

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

Code
MailProfil.SMTPUseSSL = True;

Profile
#10
Just came
Points:: 0
Joined:: Oct 8, 2012

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

Profile
#11
Just came
Points:: 0
Joined:: Oct 8, 2012

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

Profile
#12
Active user
Points:: 0
Joined:: Jun 4, 2013

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

Profile
#13
Active user
Points:: 0
Joined:: Jun 4, 2013

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

Profile
#14
Active user
Points:: 0
Joined:: Jun 4, 2013

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 ?!!!

Profile
#15
Just came
Points:: 0
Joined:: Oct 8, 2012

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

Profile
#16
Guest
Points::
Joined::

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

Profile
#17
Active user
Points:: 0
Joined:: Jun 4, 2013

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

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

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

Profile
#19
Active user
Points:: 0
Joined:: Jun 25, 2013

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

Profile
#20
Just came
Points:: 0
Joined:: Sep 5, 2014

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

Profile
#21
Guest
Points::
Joined::

Hello, Huong Tram!

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

Profile
#22
Just came
Points:: 0
Joined:: Sep 5, 2014

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

Profile
#23
Just came
Points:: 0
Joined:: Dec 19, 2022

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

Profile
#24
Administrator
Points:: 0
Joined:: Oct 3, 2019

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

Profile
#25
Just came
Points:: 0
Joined:: Dec 19, 2022

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.

Profile
#26
Administrator
Points:: 0
Joined:: Oct 3, 2019

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?

Profile
#27
Just came
Points:: 0
Joined:: Dec 19, 2022

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

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.