Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: SMTP Send Email E-Mail Message System.Net.Mail System.Net.Mail.MailMessage System.Net.Mail.MailAddress System.Net.Mail.SmtpClient System.Net.NetworkCredential
strHost = 'smtp.server.com' ;!!!!!!!!! MODIFY TO FIT YOUR NEEDS !!!!!!!! strTo = 'soandso@gmail.com' ;!!!!!!!!! MODIFY TO FIT YOUR NEEDS !!!!!!!! strFrom = 'soandso@server.com' ;!!!!!!!!! MODIFY TO FIT YOUR NEEDS !!!!!!!! strSubject = 'Sample dotNet Email' ;!!!!!!!!! MODIFY TO FIT YOUR NEEDS !!!!!!!! strBody = '<HTML><HEADER></HEADER><BODY>Hello World!</BODY></HTML>' ;!!!!!!!!! MODIFY TO FIT YOUR NEEDS !!!!!!!! strUser = 'SoandSo' ;!!!!!!!!! MODIFY TO FIT YOUR NEEDS !!!!!!!! strPassword = 'SuperSecret' ;!!!!!!!!! MODIFY TO FIT YOUR NEEDS !!!!!!!! strAttachment = 'c:\myfile.txt' ;!!!!!!!!! MODIFY TO FIT YOUR NEEDS !!!!!!!! nPort = 25 ;!!!!!!!!! MODIFY TO FIT YOUR NEEDS !!!!!!!! nPort = ObjectType( "I4", nPort ) ObjectClrOption ("use","System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") _TRUE = ObjectType( "BOOL", @TRUE ) _FALSE = ObjectType( "BOOL", @FALSE ) ;NetworkCredential = ObjectClrNew( 'System.Net.NetworkCredential', strUser, strPassword) MailAddress_From = ObjectClrNew( 'System.Net.Mail.MailAddress', strFrom ) MailAddress_To = ObjectClrNew( 'System.Net.Mail.MailAddress', strTo ) MailMessage = ObjectClrNew( 'System.Net.Mail.MailMessage', MailAddress_From, MailAddress_To ) MailMessage.IsBodyHtml = _True MailMessage.Subject = strSubject MailMessage.Body = strBody Attachment = ObjectClrNew('System.Net.Mail.Attachment', strAttachment) Mailmessage.Attachments.Add( Attachment ) SmtpClient = ObjectClrNew( 'System.Net.Mail.SmtpClient' ) SmtpClient.Host = strHost ; Specify SMTP Host SmtpClient.Port = nPort ; Port Number SmtpClient.UseDefaultCredentials = _TRUE ; Use SSL ;SmtpClient.Credentials = NetworkCredential ; Authentication ;SmtpClient.EnableSsl = _TRUE ; Use SSL SmtpClient.Send( MailMessage ) ; Send Exit
Article ID: W17838
Filename: Simple SMTP Email Message.txt
File Created: 2013:12:11:10:27:08
Last Updated: 2013:12:11:10:27:08