Problem with sending mail
hi,
i am facing a wierd problem.
in my application i have written a code to send mail with attachments.
problem is that sometimes the mail is sent and sometimes not.
i dont get any errors even when the mail is not sent.
it also happens that the same mail sent to 2-3 addresses is received on one address and not on others.
i dont know what is going wrong. what i feel is that if there is anything wrong with it should never send mail or to any address.
Is there any encoding of attachments to be done or so.
i am doing following things in my code:
MailMessage myMailMsg = new MailMessage();
myMailMsg.To = ToList;
myMailMsg.From = mailid;
myMailMsg.Cc = CcList;
myMailMsg.Subject = subject;
myMailMsg.Body = bodymsg;
myMailMsg.BodyFormat = MailFormat.Html;
SmtpMail.SmtpServer=smtpServer;
//the attachements are attached in a loop using the following code
MailAttachment MyAttachment = new MailAttachment(upfilepath);
myMailMsg.Attachments.Add(MyAttachment);
//And send the mail using
SmtpMail.Send(myMailMsg);
The values come properly in myMailMsg object. i checked it through debugging.
please help me out.
Regards,
Niks
|