Hello all!
I want to send an email from my console application.
So there is 3 string a,b,c that the user have to enter.
Then i want this 3 information to mail me.
SO:
program....
SendMail HERE
program...
I've got a gmail account.
Sorry if you cant understand :( My eng is very bad.
I need a source code for it, thank you very much!
Loading
Master BillaPosted Sep 29, 2009, 11:45 PM
You just copy this code and paste
private void SendEmailWithAttamentWithSyncMode()
{
try
{
MailMessage message = new MailMessage();
//from address
message.From = new MailAddress("fromEmailAddress", "Messsage");
// to address
message.To.Add(new MailAddress("ToEmailAddress", "The CodeGain Info"));
// set content email
message.Body = "This is auto generated email dont reply and you have two attachements also";
//set this email content display user inbox like Html format
message.IsBodyHtml = true;
// this is the heading of the email
message.Subject = "The CodeGain.com Message";
SmtpClient emailClient = new SmtpClient("serverIP", 25);// 25 is default for SMTP server
emailClient.DeliveryMethod = SmtpDeliveryMethod.Network;
// set users to default use the default credential
emailClient.UseDefaultCredentials = true;
emailClient.Send(message);
}
catch (SmtpException smtpex)
{
throw smtpex;
}
catch (Exception ex)
{
throw ex;
}
}
thank you