am using .NET 2.0 Visual Studio 2005 using C#.
I'm attaching files using System.Net.Mail.Attachment.Add(...)
My problem is, that this is working fine, when I'm debugging with visual studio.
but in Livemode the file-attachments seems not to work. (no error is thrown but I don't get the mail)
Calling the site via localhost also sends no mail.
Sending Mails using this System.Net.Mail-Class always works fine (without attachments).
Please help!!
here is the codec# Code:
xxxxxxxxxxxxxxxxxxxxxxxx public void sendmail(string frm, string to, string bcc, string cc, string sub, string bdy, string smtpserver, string smtpusername, string smtppassword) { int fileLen=0; string pathAndFile = ""; try { if (smtpusername != "" && smtppassword != "") { System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage(frm, to, sub, bdy); if (bcc != "") msg.Bcc.Add(bcc); if (cc != "") msg.CC.Add(cc); if (txtFileUpload.HasFile) { pathAndFile = txtFileUpload.PostedFile.FileName; fileLen = (txtFileUpload.PostedFile.ContentLength / 1000); if (fileLen > 500) { CreateMessageAlert(this, "Maximum File Size Limit is 500 kbps", "alert", "MyMessages.aspx?link=3"); return; } System.Net.Mail.Attachment attachment = new System.Net.Mail.Attachment(pathAndFile); msg.Attachments.Add(attachment); } msg.IsBodyHtml = true; System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient(smtpserver); smtpClient.UseDefaultCredentials = false; smtpClient.Credentials = new System.Net.NetworkCredential(smtpusername, smtppassword); smtpClient.Send(msg); if (pathAndFile != "") { msg.Attachments.Dispose(); } } else { System.Web.Mail.MailMessage msg = new System.Web.Mail.MailMessage(); msg.From = frm; msg.To = to; msg.Bcc = bcc; msg.Cc = cc; msg.Subject = sub; if (pathAndFile!="") { msg.Attachments.Add(new MailAttachment(pathAndFile)); } msg.BodyFormat = MailFormat.Html; msg.Body = bdy; SmtpMail.SmtpServer = smtpserver; SmtpMail.Send(msg); if (pathAndFile != "") { msg.Attachments.Clear(); // msg.Attachments.Dispose(); } } } catch {} } sendmail(Session["userid"].ToString(), email, tempbcc, tempcc, txtSubject.Text, body, smtpserver, smtpusername, smtppassword);




Reply With Quote