使用 SendGrid 发送带附件的电子邮件

编程入门 行业动态 更新时间:2024-10-22 15:24:48
本文介绍了使用 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 发送带附件的电子邮件

本文发布于:2023-11-06 06:35:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1562954.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:附件   电子邮件   SendGrid

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!