전자 메일 주소로 여러 파일을 메일로 보내야합니다. 파일의 확장명은 .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이나 핫메일과 같은 완전히 다른 제공 업체)로 보내보십시오. 수신 메일 서버 때문에 기분이 좋습니다! – banging