如何使用sendgrid将文档文件附加到邮件 [英] How to attach document files to the mails by using sendgrid
本文介绍了如何使用sendgrid将文档文件附加到邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想附上一些上传时间的文件,但是没有收到我可以保存文件的电子邮件,除了'AddAttachments'方法外,一切都很好。
我尝试过:
I would like to attach some files which are at uploading time, but not getting emails where I could save the files everything is good to run except 'AddAttachments' method.
What I have tried:
public ContentResult CompleteAssignedTask(int AssignedTaskId, string FromEmail, string[] fileNames)
{
var client = new SendGridClient("mycode");
var from = new EmailAddress("director@gmail.com", "The awsome");
var to = new EmailAddress(customer.Email, customer.CustName);
var htmlContent = body;
var msg = MailHelper.CreateSingleEmail(from, to, taskRecord.Subject, "", htmlContent);
msg.AddAttachments(fileNames);
var response = client.SendEmailAsync(msg);
}
推荐答案
你以错误的方式调用API。
如果您查看API,您会看到方法'AddAttachments'
不接受IEnumerable< string>作为输入参数。
You call the API the wrong way.
If you have a look at the API you will see that the method 'AddAttachments'
does not accept IEnumerable<string> as input parameter.
public void AddAttachments(IEnumerable<Attachment> attachments)
{
...
}
它接受IEnumerable< Attachment>。
你应该从GitHub下载源代码
https://github.com/sendgrid/sendgrid-csharp
以了解API。
It accepts IEnumerable<Attachment>.
You should download the source code from GitHub
https://github.com/sendgrid/sendgrid-csharp
in order to understand the API.
这篇关于如何使用sendgrid将文档文件附加到邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文