All,
I have a simple .net form with a subject, body, a fileupload area to attach a file and an area for email address entry, So a basic page but when i try to send an email the code will not work, Any help would be great.
does anyone know how to send mail via .net here is my code and it will not send:
MailMessage message = new MailMessage( );
//set the addresses
message.From = new MailAddress( "xxxx@xx.xxx");
message.To.Add( strEmailsSelecte d);
//Create an instance of Attachment class
Attachment attachment;
attachment = new Attachment(FileUplo ad1.FileName) ;
//Add attachment in instance of MailMessage class
message.Attachments .Add(attachment) ;
//set the content
message.Subject = strEmailSubject;
message.Body = strEmailBody;
//send the message
SmtpClient client = new SmtpClient() ;
try
{
client.Send( message);
}
catch (Exception ex)
{
Console.WriteLine( "Exception caught in CreateMessageWithAt tachment( ): {0}",
ex.ToString( ));
}
message.Dispose( );