6
我使用SmtpClient
類發送郵件並附加文件。一切似乎工作正常,除了在電子郵件附件中的文件名稱filestest.docx
而不是test.docx
。默認情況下會追加文件所在的文件夾名稱。我想只看到實際的文件名。使用SmtpClient發送文件附件
msg.Attachments.Add(new Attachment("I:/files/test.docx"));
任何想法?
我使用SmtpClient
類發送郵件並附加文件。一切似乎工作正常,除了在電子郵件附件中的文件名稱filestest.docx
而不是test.docx
。默認情況下會追加文件所在的文件夾名稱。我想只看到實際的文件名。使用SmtpClient發送文件附件
msg.Attachments.Add(new Attachment("I:/files/test.docx"));
任何想法?
向您的附件添加ContentType。
System.Net.Mime.ContentType contentType = new System.Net.Mime.ContentType();
contentType.MediaType = System.Net.Mime.MediaTypeNames.Application.Octet;
contentType.Name = "test.docx";
msg.Attachments.Add(new Attachment("I:/files/test.docx", contentType));
...
嗨Jac ...添加內容類型修復了這個問題。謝謝 – user2588040
發佈您的c#和HTML代碼。你的代碼中可能有硬編碼的文件名。 – Learner
如果您將test.docx移動到「I:/test.docx」它是否仍然出現? – Marek