本文介绍了使用 SendGrid 发送带附件的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
var myMessage = new SendGridMessage();
myMessage.From = new MailAddress("info@email");
myMessage.AddTo("Cristian <myemail@email>");
myMessage.Subject = user.CompanyName + "has selected you!";
myMessage.Html = "<p>Hello World!</p>";
myMessage.Text = "Hello World plain text!";
// myMessage.AddAttachment("C: est est.txt");
var apiKey = "";
var transportWeb = new Web(apiKey);
transportWeb.DeliverAsync(myMessage);
基本上我可以使电子邮件正常工作,而当我尝试添加附件时,它不会发送.我尝试了不同的路径和编写路径的不同方式,我不确定出了什么问题,我发现的每个教程都表明它应该像这样工作.
Basically I can make the email work, and the moment I attempt to add an attachment it doesn't send it. I tried different paths and different ways of writing the path, I am not sure what is going wrong, every single tutorial I have found shows it should work like this.
推荐答案我让它工作了,结果我只需要一个虚拟路径:
I got it to work, turns out I just needed a virtual path:
myMessage.AddAttachment(Server.MapPath(@"~imglogo.png"));更多推荐
使用 SendGrid 发送带附件的电子邮件
发布评论