我必須將多個文件郵寄到一個電子郵件地址。這些文件需要具有.tcx文件擴展名。這些實際上是xml文件(Garmin自行車日誌)。System.net.mail附件獲取.xml文件擴展名
顯然,當接收者收到郵件時,附件名爲xxxxx.tcx.xml。我如何強制郵件程序不要更改附件文件名稱?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
using System.IO;
namespace stravamailer
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
var files = Directory.GetFiles("E:\\JurgenS\\Downloads\\allrides");
for (int i = 0; i < files.Length; i++)
{
MailMessage oMail = new MailMessage();
oMail.Body = "";
oMail.From = new MailAddress("[email protected]","Jurgen Stillaert");
oMail.Subject = "";
oMail.To.Add(new MailAddress("[email protected]"));
Attachment att = new Attachment(files[i]);
att.Name = Path.GetFileName(files[i]);
oMail.Attachments.Add(att);
SmtpClient oSmtp = new SmtpClient("uit.telenet.be");
oSmtp.Send(oMail);
}
}
}
}
嘗試將它發送到另一個電子郵件地址(完全不同的提供商;如Gmail或Hotmail),以查看附件是否也被重命名。我有一種感覺,這是因爲接收郵件服務器! – banging