Loads a RFC822 message ( *.eml) file to current SmtpMail instance.
[Visual Basic] Public Sub LoadMessage( _ fileName As String _ ) Public Sub LoadMessage( _ data As Byte () _ )
[C#] public void LoadMessage( string fileName ); public void LoadMessage( byte [] data );
[C++] public: void LoadMessage( String^ fileName ); public: void LoadMessage( <unsigned char>^ data );
[JScript] public function LoadMessage( fileName : String ); public function LoadMessage( data : Byte [] );
Parameters
Example
[Visual Basic, C#, C++] To get the full samples of EASendMail, please refer to Samples section.
[VB - Edit and Send Email] Imports EASendMail Sub SendMail() Try Dim oMail As SmtpMail = New SmtpMail("TryIt") oMail.From = New MailAddress("from@adminsystem.com") oMail.To.Add(New MailAddress("to@adminsystem.com")) oMail.Subject = "test subject" oMail.TextBody = "test body" oMail.SaveAs("c:\test.eml", True) oMail.Reset() oMail.LoadMessage("c:\test.eml") ' change subject oMail.Subject = "new email subject" Dim oServer As SmtpServer = New SmtpServer("myserveraddress") ' SMTP user authentication oServer.User = "myusername" oServer.Password = "mypassword" ' Most mordern SMTP servers require SSL/TLS connection now. ' ConnectTryTLS means if server supports SSL/TLS, SSL/TLS will be used automatically. oServer.ConnectType = SmtpConnectType.ConnectTryTLS Dim oSmtp As SmtpClient = New SmtpClient oSmtp.SendMail(oServer, oMail) Console.WriteLine("message was sent") Catch exp As Exception Console.WriteLine("Exception: Common: {0}", exp.Message) End Try End Sub
[C# - Edit and Send Email] using System; using EASendMail; void SendMail() { try { SmtpMail oMail = new SmtpMail("TryIt"); oMail.From = new MailAddress("from@adminsystem.com"); oMail.To.Add( new MailAddress("to@adminsystem.com")); oMail.Subject = "test subject"; oMail.TextBody = "test body"; // save email oMail.SaveAs("c:\\test.eml", true); oMail.Reset(); oMail.LoadMessage("c:\\test.eml"); // change subject oMail.Subject = "new email subject"; SmtpServer oServer = new SmtpServer("myserveraddress"); // SMTP user authentication oServer.User = "myusername"; oServer.Password = "mypassword"; // Most mordern SMTP servers require SSL/TLS connection now. // ConnectTryTLS means if server supports SSL/TLS, SSL/TLS will be used automatically. oServer.ConnectType = SmtpConnectType.ConnectTryTLS; SmtpClient oSmtp = new SmtpClient(); oSmtp.SendMail(oServer, oMail); Console.WriteLine("message was sent"); } catch(Exception exp) { Console.WriteLine("Exception: {0}", exp.Message); } }
[C++/CLI - Edit and Send Email] using namespace System; using namespace EASendMail; void SendMail() { try { SmtpMail ^oMail = gcnew SmtpMail("TryIt"); oMail->From = gcnew MailAddress("from@adminsystem.com"); oMail->To->Add(gcnew MailAddress("to@adminsystem.com")); oMail->Subject = "test subject"; oMail->TextBody = "test body"; // save copy oMail->SaveAs("c:\\test.eml", true); oMail->Reset(); oMail->LoadMessage("c:\\test.eml"); // change subject oMail->Subject = "new email subject"; SmtpServer ^oServer = gcnew SmtpServer("myserveraddres"); // SMTP user authentication oServer->User = "myusername"; oServer->Password = "mypassword"; // Most mordern SMTP servers require SSL/TLS connection now. // ConnectTryTLS means if server supports SSL/TLS, SSL/TLS will be used automatically. oServer->ConnectType = SmtpConnectType::ConnectTryTLS; SmtpClient ^oSmtp = gcnew SmtpClient(); oSmtp->SendMail(oServer, oMail); Console::WriteLine("message was sent"); } catch(Exception ^exp) { Console::WriteLine("Exception: {0}", exp->Message); } }
See Also