Hi drifter,
I tested your sample,
You add attachments too early,
The item.GetTempFilePath() returns the template path of item, it is a '.rex' file
Before you add attachments, you can use item.MoveTo(NEWPATH) method
This is my demo
- protected void Button1_Click(object sender, EventArgs e)
- {
- System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
- msg.From = new System.Net.Mail.MailAddress("[email protected]");
- msg.To.Add("[email protected]");
- msg.Subject = "Nbk Jeff please save";
- msg.Body = " as Such attachments";
-
- foreach (AttachmentItem item in UploadAttachments1.Items)
- {
- if (!item.Checked) continue;
-
-
-
- string attachmentPath = Server.MapPath("~/") + "UploadFiles\\" + item.FileGuid.ToString() + "_" + item.FileName;
- item.MoveTo(attachmentPath);
- System.Net.Mail.Attachment ma = new System.Net.Mail.Attachment(attachmentPath);
- msg.Attachments.Add(ma);
- }
-
- System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient("smtp.ccc.com", 25);
- smtpClient.UseDefaultCredentials = false;
- smtpClient.Credentials = new System.Net.NetworkCredential("[email protected]", "YOUR PASSWORD");
- smtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
- smtpClient.Send(msg);
- }
Regards,
Jeff