I have been trying to send an email in C# (below is the code).
I want to send an attachment with this email. When I run this code in my debugger with its instance of IIS it works fine
however, when I run it through our IIS 7 server it gets stripped off.
We have checked our anti virus and that is not the issue, I have run it
with both the credential code commented in and out and no change.
any ideas why i cannot get an attachment through our IIS server?
MailMessage message = new System.Net.Mail.MailMessage();
message.To.Add("test@test.com");
message.Subject = "Project Created";
message.From = new MailAddress("helpdesk@test.com");
message.Body = "You have received a project request from " + TxtContactName.Text + " Project Name: " + TxtProjectName.Text + " Priority: " + DDLPriority.SelectedValue.ToString() + " Business Area: " + DDLBusinessArea.SelectedValue.ToString();
if (FileUpload1.FileName.Length > 0)
{
if (File.Exists(FileUpload1.PostedFile.FileName))
message.Attachments.Add(new Attachment(FileUpload1.PostedFile.FileName, MediaTypeNames.Application.Octet));
}
SmtpClient smtp = new SmtpClient("10.1.1.118");
smtp.Credentials = CredentialCache.DefaultNetworkCredentials;
//NetworkCredential cred = new NetworkCredential();
//cred.UserName = test@test.com;
//cred.Password = "test1";
//cred.Domain = "test.com";
//smtp.UseDefaultCredentials = false;
//smtp.Credentials = cred;
//smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Send(message);
No comments:
Post a Comment