Csharp/C#教程:用附件撰写Outlook中的电子邮件分享


用附件撰写Outlook中的电子邮件

在我的应用程序中,我有一个要求,即如果用户点击发票编号,生成的发票声明将附加到outlook中的撰写电子邮件中。 使用下面的代码我能够发送自动电子邮件,但我需要撰写并打开Outlook窗口供用户查看和编辑内容。 不要寄。 请帮助。

public void pdfStatement(string InvoiceNumber) { InvoiceNumber = InvoiceNumber.Trim(); string mailServer = "server"; string fileName = InvoiceNumber; string filePath = Server.MapPath("~/Content/reports/"); string messageBody = "Its an automated test email, please ignore if you receive this."; CreateMessageWithAttachment(mailServer, filePath, fileName, messageBody); } public void CreateMessageWithAttachment(string mailServer, string filePath, string fileName, string messageBody) { MailMessage message = new MailMessage ( "user@domain.com", "user@domain.com", "TestEmail", messageBody); filePath = filePath + fileName + ".pdf"; // Create the file attachment for this e-mail message. Attachment attach = new Attachment(filePath); attach.Name = fileName + ".pdf"; // Add the file attachment to this e-mail message. message.Attachments.Add(attach); //Send the message. SmtpClient client = new SmtpClient(mailServer); var AuthenticationDetails = new NetworkCredential("user", "password"); client.Credentials = AuthenticationDetails; client.Send(message); } 

不确定这是否会有所帮助,但是如何在页面中创建表单并允许用户键入/查看他们发送的内容。 这里有样品

预览按钮也可以提供帮助

编辑:然后你需要使用Microsoft.Office.Interop.Outlook命名空间来创建一个邮件项目。
这是第一个样本
从示例中,MailItem类(oMsg)还有一个Display()方法,该方法应显示创建的电子邮件。
第二个示例(ASP.NET版本)

上述就是C#学习教程:用附件撰写Outlook中的电子邮件分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/cdevelopment/990476.html

(0)
上一篇 2021年12月24日
下一篇 2021年12月24日

精彩推荐