MailAddress^ from = gcnew MailAddress("from mailaddress", "xxxxxfrom");
MailAddress^ to = gcnew MailAddress("to mail address", "xxxxxto");
MailMessage^ message = gcnew MailMessage(from, to);
// message.Subject = "Using the SmtpClient class.";
message->Subject = "Using the SmtpClient class."; message->Body = "Using this feature, you can send an e-mail message from an application very easily.";
String^ sSource = "C:\\realtek.log";
Attachment^ attachmentfile = gcnew Attachment(sSource); message->Attachments->Add(attachmentfile); SmtpClient^ client = gcnew SmtpClient("hostname"); client->SendCompleted += gcnew SendCompletedEventHandler(SendCompletedCallback); String^ userState = "test message1";
// Include credentials if the server requires them.
client->Credentials = CredentialCache::DefaultNetworkCredentials;
try
{
client->Send(message);
}
catch(Exception^ ex)
{
MessageBox::Show(ex->InnerException->InnerException->Message);
}
For any queries just mail me.
Regards
Ajith
Subscribe to:
Post Comments (Atom)


No comments:
Post a Comment