[progress Communities] [progress Openedge Abl] Forum Post: Re: Upgrade For Smtpmail.p To...

Status
Not open for further replies.
O

oedev

Guest
This not by all means a full replacement for smtpmail.p, but shows the basics of sending an email using the .NET framework. In this example I was using gmail to send from (you have to generate a special password from gmail to do this). using System.Net.*. using System.Net.Mail.*. DEF VAR smtp AS SmtpClient. DEF VAR fromAddress AS MailAddress. DEF VAR toAddress AS MailAddress. DEF VAR ccAddress AS MailAddress. DEF VAR emailmessage AS MailMessage. DEF VAR ATTACHMENT AS Attachment. DEF VAR fromPassword AS CHAR INIT "abcdefghi". DEF VAR subject AS CHAR INIT "Test". DEF VAR body AS CHAR INIT "Just testing message". fromAddress = new MailAddress("fromemail@gmail.com"). toAddress = new MailAddress("toemail@somewherecom"). ccAddress = new MailAddress("ccemail@somewhere.com"). smtp = new SmtpClient(). smtp:Host = "smtp.gmail.com". smtp:port = 587. smtp:EnableSsl = TRUE. smtp:DeliveryMethod = SmtpDeliveryMethod:Network. smtp:UseDefaultCredentials = FALSE. smtp:Credentials = new NetworkCredential(fromAddress:Address, fromPassword). emailmessage = new MailMessage(fromAddress, toAddress). emailmessage:cc:ADD(ccAddress). emailmessage:Subject = subject. emailmessage:Body = body. ATTACHMENT = NEW Attachment("c:\temp\file.html"). emailmessage:attachments:ADD(attachment). smtp:Send(emailmessage).

Continue reading...
 
Status
Not open for further replies.
Top