Loads a RFC822 message ( *.eml) file to current SmtpMail instance.
[Visual Basic]
Public Sub LoadMessageAsync( _
fileName As String _
)
[C#]
public void LoadMessageAsync(
string fileName
);
[C++]
public: void LoadMessageAsync(
String^ fileName
);
[JScript]
public function LoadMessageAsync(
fileName : String
);
Parameters
Examples
[Visual Basic, C#, JavaScript] The following example demonstrates how to send email in Windows 8 Store App. To get the full samples of EASendMail, please refer to Samples section.
[C# - Edit and Send Email from Windows Store Apps - XAML]
using EASendMail;
using System.Threading.Tasks;
private async Task SendEmail()
{
String Result = "";
try
{
SmtpMail oMail = new SmtpMail("TryIt");
SmtpClient oSmtp = new SmtpClient();
// Set sender email address, please change it to yours
oMail.From = new MailAddress("test@emailarchitect.net");
// Add recipient email address, please change it to yours
oMail.To.Add(new MailAddress("support@emailarchitect.net"));
// Set email subject and body text
oMail.Subject = "test email from C# XAML project";
oMail.TextBody = "this is a test email sent from Windows Store App, do not reply";
// Save to disk and load it back
await oMail.SaveAsAsync("ms-appdata:///local/test.eml", true );
oMail.Reset();
await oMail.LoadMessageAsync("ms-appdata:///local/test.eml");
// Change email subject
oMail.Subject = "new subject";
// Your SMTP server address
SmtpServer oServer = new SmtpServer("smtp.emailarchitect.net");
// User and password for ESMTP authentication
oServer.User = "test@emailarchitect.net";
oServer.Password = "testpassword";
// If your SMTP server requires TLS connection on 25 port, please add this line
// oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;
// If your SMTP server requires SSL connection on 465 port, please add this line
// oServer.Port = 465;
// oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;
await oSmtp.SendMailAsync(oServer, oMail);
Result = "Email was sent successfully!";
}
catch (Exception ep)
{
Result = String.Format("Failed to send email with the following error: {0}", ep.Message);
}
// Display Result by Diaglog box
Windows.UI.Popups.MessageDialog dlg = new
Windows.UI.Popups.MessageDialog(Result);
await dlg.ShowAsync();
}
[VB - Edit and Send Email from Windows Store Apps - XAML]
Imports EASendMail
Private Async Function SendEmail() As Task
Dim Result As String = ""
Try
Dim oMail As New SmtpMail("TryIt")
Dim oSmtp As New SmtpClient()
' Set sender email address, please change it to yours
oMail.From = New MailAddress("test@emailarchitect.net")
' Add recipient email address, please change it to yours
oMail.To.Add(New MailAddress("support@emailarchitect.net"))
' Set email subject and body text
oMail.Subject = "test email from VB XAML project"
oMail.TextBody = "this is a test email sent from Windows Store App, do not reply"
' Save email to disk and load it back
Await oMail.SaveAsAsync("ms-appdata:///local/test.eml", True)
oMail.Reset()
Await oMail.LoadMessageAsync("ms-appdata:///local/test.eml")
' change subject
oMail.Subject = "new Subject"
' Your SMTP server address
Dim oServer As New SmtpServer("smtp.emailarchitect.net")
' User and password for ESMTP authentication
oServer.User = "test@emailarchitect.net"
oServer.Password = "testpassword"
' If your SMTP server requires TLS connection on 25 port, please add this line
' oServer.ConnectType = SmtpConnectType.ConnectSSLAuto
' If your SMTP server requires SSL connection on 465 port, please add this line
' oServer.Port = 465
' oServer.ConnectType = SmtpConnectType.ConnectSSLAuto
Await oSmtp.SendMailAsync(oServer, oMail)
Result = "Email was sent successfully!"
Catch ep As Exception
Result = String.Format("Failed to send email with the following error: {0}", ep.Message)
End Try
' Display Result by Diaglog box
Dim dlg As New Windows.UI.Popups.MessageDialog(Result)
Await dlg.ShowAsync()
End Function
[JavaScript - Edit and Send Email from Windows Store Apps - HTML5]
function sendMail() {
var result = "";
var oMail = new EASendMail.SmtpMail("TryIt");
var oSmtp = new EASendMail.SmtpClient();
// Set sender email address, please change it to yours
oMail.from = new EASendMail.MailAddress("test@emailarchitect.net");
// Add recipient email address, please change it to yours
oMail.to.add(new EASendMail.MailAddress("support@emailarchitect.net"));
// Set email subject and body text
oMail.subject = "test email from JavaScript HTML5 project";
oMail.textBody = "this is a test email sent from Windows Store App, do not reply";
// save email to disk and load it back
oMail.saveAsAsync("ms-appdata:///local/test.eml", true)
.then(function () {
oMail.reset();
return oMail.loadMessageAsync("ms-appdata:///local/test.eml");
})
.then(function () {
// change subject
oMail.Subject = "new subject"
// Your SMTP server address
var oServer = new EASendMail.SmtpServer("smtp.emailarchitect.net");
// User and password for ESMTP authentication
oServer.user = "test@emailarchitect.net";
oServer.password = "testpassword";
// If your SMTP server requires TLS connection on 25 port, please add this line
// oServer.connectType = EASendMail.SmtpConnectType.connectSSLAuto;
// If your SMTP server requires SSL connection on 465 port, please add this line
// oServer.port = 465;
// oServer.connectType = EASendMail.SmtpConnectType.connectSSLAuto;
return oSmtp.sendMailAsync(oServer, oMail);
})
.done(function () {
result = "Email was sent successfully!";
// Display Result by Diaglog box
(new Windows.UI.Popups.MessageDialog(result, "Success")).showAsync();
},
// error handler
function (e) {
// because javascript exception only gives the stack trace messages, but it is not
// real description of exception, so we give a property lastErrorMessage for javascript.
if (oMail.lastErrorMessage != "") {
result = oMail.lastErrorMessage;
}
else if (oSmtp.lastErrorMessage != "") {
result = oSmtp.lastErrorMessage;
}
else {
result = e.message;
}
oSmtp.close();
// Display Result by Diaglog box
(new Windows.UI.Popups.MessageDialog(result, "Error Information")).showAsync();
});
}
See Also