gpt4 book ai didi

c# - 在 C# 中设置电子邮件附件名称

转载 作者:IT王子 更新时间:2023-10-29 03:57:26 24 4
gpt4 key购买 nike

我添加这样的附件:

System.Net.Mail.Attachment attachment = new System.Net.Mail.Attachment(AttachmentPath);   
msg.Attachments.Add(attachment);

但我想让它附加为不同的名称,实际文件名很长且令人困惑我希望它附加为“file.txt”,有没有一种简单的方法可以做到这一点而不必制作文件副本?

最佳答案

怎么样:

System.Net.Mail.Attachment attachment = new System.Net.Mail.Attachment(attachmentPath);
attachment.Name = "file.txt"; // set name here
msg.Attachments.Add(attachment);

关于c# - 在 C# 中设置电子邮件附件名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7149148/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com