SMTP MailMessage MailAddressCollection

A

Andrew

hi all,

I have this code but it doesn't work. Can you help me ?

MailMessage message = new MailMessage();

MailAddress MA_from = new MailAddress(msg.From, "WHOEVER",
System.Text.Encoding.UTF8);
message.From = MA_from;

MA_To = new MailAddress("(e-mail address removed)", "ME", System.Text.Encoding.UTF8);
message.To.Add(MA_To);

message.Subject = msg.Subject;
message.Body = "BODY";

MailAddress MA_CC = new MailAddress("ABC", "** TestAttachment **");
message.CC.Add(MA_CC);

SmtpClient client = new SmtpClient(var.hostName, var.portNo);
client.SendAsync(message);


Thanks in advance

regards,
Andrew
 
A

Andrew

I got this error:

System.Net.Mail.SmtpException: Failure sending mail. --->
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.Mail.MailMessage'.
at System.Net.Mail.MailMessage.get_AlternateViews()
at System.Net.Mail.MailMessage.SetContent()
at System.Net.Mail.SmtpClient.SendMailCallback(IAsyncResult result)
--- End of inner exception stack trace ---
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top