Sending mail triggered by script AVEVA 2023 R2 SP1

Hi,
I would like to create script in instance, which will send mail to customer via mail.

I found something like this in web:

System.Web.Mail.SmtpMail.SmtpServer = "YourMailServer.com";
System.Web.Mail.SmtpMail.Send

(
   {from: } "IAS@ABC.com",
   
    {to: } "JoeEngineer@ABC.com, FredEngineer@ABC.com, PhoneNumber@messaging.XYZ.com",

    {subject: } "VALUE XX = 0",

    {body: } me.MailMessage
);
me.SendTrigger = 0;


Unfortunately i cannot find the example of setting up SMTP (login/password/port etc.)
Do you have any ideas how to configure sending mails?

AVEVA 2023 R2 SP1

 

Parents
  • Hi Patryk!

    Sending emails from System Platform is very useful and I have created this feature in several scenarios.

    I hope the example below gets you started.

    A tip to enrich your content is to use html code in your body segment.
    This will allow you to add formatting and even images in your email.

    Happy coding!

    try
    	dim client = new System.Net.Mail.SmtpClient("smtp.domain.local");
    	dim basicAuthenticationInfo = new System.Net.NetworkCredential("user", "password");
    	client.Credentials = basicAuthenticationInfo;
    	dim mail = new System.Net.Mail.MailMessage();
    	mail.To.Add(new System.Net.Mail.MailAddress("destination@customer.com"));
    	mail.From = new System.Net.Mail.MailAddress("spnotifyer@customer.com");
    	mail.Subject = "Message from SP";
    	mail.Body = "Hello there!";
    	client.Send(mail);
    	LogMessage("mail sent");
    catch
    	LogWarning("exception in creating email: "+error);
    endtry;
    
    me.SendTrigger = 0;

    (example of email with html content)

Reply
  • Hi Patryk!

    Sending emails from System Platform is very useful and I have created this feature in several scenarios.

    I hope the example below gets you started.

    A tip to enrich your content is to use html code in your body segment.
    This will allow you to add formatting and even images in your email.

    Happy coding!

    try
    	dim client = new System.Net.Mail.SmtpClient("smtp.domain.local");
    	dim basicAuthenticationInfo = new System.Net.NetworkCredential("user", "password");
    	client.Credentials = basicAuthenticationInfo;
    	dim mail = new System.Net.Mail.MailMessage();
    	mail.To.Add(new System.Net.Mail.MailAddress("destination@customer.com"));
    	mail.From = new System.Net.Mail.MailAddress("spnotifyer@customer.com");
    	mail.Subject = "Message from SP";
    	mail.Body = "Hello there!";
    	client.Send(mail);
    	LogMessage("mail sent");
    catch
    	LogWarning("exception in creating email: "+error);
    endtry;
    
    me.SendTrigger = 0;

    (example of email with html content)

Children
No Data