通过电子邮件发送C#生成CSV文件嵌入到电子邮件莲花记下 [英] c# generated csv file sent via email embedded to bottom of email in lotus note
问题描述
我有这个weired问题的CSV附件使用.NET SmtpClient出现在电子邮件,而不是附着在Lotus注意底部通过电子邮件发送。我只是不知道如何计算出来,我要客户端计算机不能访问使调试非常困难。什么是我需要知道的可能的步骤我可以采取和可能的陷阱?
I am having this weired issue that CSV attachment sent via email using .NET SmtpClient appeared at the bottom of the email rather than attachment in Lotus Note. I just don’t know how to figure it out and I have no access to client computer makes debugging very hard. What are the possible steps I can take and possible gotchas I need to be aware of?
code是如下:
var smtpClient = new SmtpClient
{
Host = ConfigurationManager.AppSettings["smtpServer"],
Port = Convert.ToInt32(ConfigurationManager.AppSettings["smtpPort"])
};
var mailMessage = new MailMessage();
mailMessage.Attachments.Add(new Attachment(attachment, contentType));
//ContentType = "text/csv";
//attachment is the temp file disk path
感谢。
推荐答案
这是一个有点影响力,但你可能要设置的内容处置附件的。
This is a bit of a reach, but you may want to set the content-disposition of the attachment.
var mailMessage = new MailMessage();
Attachment data = new Attachment(attachment, contentType);
ContentDisposition disposition = data.ContentDisposition;
disposition.FileName = "message.csv";
mailMessage.Attachments.Add(data);
摘自: 的http://msdn.microsoft.com/en-us/library/system.net.mail.attachment.contentdisposition.aspx
这篇关于通过电子邮件发送C#生成CSV文件嵌入到电子邮件莲花记下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!