撰写电子邮件与附件的前景 [英] compose email in outlook with attachment
问题描述
在我的申请,我如果用户点击生成的发票statesment连接到Outlook中的电子邮件组成的发票号码,其中一个要求。使用code下面我能够发送自动电子邮件,但我只是需要撰写和打开Outlook窗口供用户查看和编辑的内容。不要寄。请帮助。
公共无效pdfStatement(字符串InvoiceNumber) { InvoiceNumber = InvoiceNumber.Trim();
字符串的邮件服务器=服务器;
字符串文件名= InvoiceNumber;
字符串文件路径=使用Server.Mappath(〜/内容/报告/);
字符串消息体=它自动化测试电子邮件,请您收到此忽略不计。
CreateMessageWithAttachment(邮件服务器,文件路径,文件名,消息体);
}
公共无效CreateMessageWithAttachment(字符串的邮件服务器,文件路径字符串,字符串文件名,字符串消息体) { 消息MAILMESSAGE新= MAILMESSAGE(
user@domain.com
user@domain.com
testemail子
消息体); 文件路径文件路径=文件名+ +.PDF //创建此电子邮件文件附件。
附件附加=新的附件(文件路径);
attach.Name =文件名+.PDF
//文件附件添加到该电子邮件。
message.Attachments.Add(连接);
//发送消息。
SmtpClient客户端=新SmtpClient(邮件服务器);
VAR AuthenticationDetails =新的NetworkCredential(用户,密码);
client.Credentials = AuthenticationDetails;
client.Send(消息);
}
不知道这是否会帮助,但如何对你刚刚创建在临页面的表单,允许用户输入/看到他们来发送。
样品这里
另外preVIEW按钮可以帮助
编辑:
然后ü需要使用Microsoft.Office.Interop.Outlook命名空间中创建一个邮件项目。
的在这里的第一个采样
从样本的类的MailItem(OMSG)还具有应显示创建的电子邮件显示器()方法。
<一href=\"http://w3mentor.com/learn/asp-dot-net-c-sharp/c-interoperability/sending-mail-using-outlook-in-c-asp-net/\"相对=nofollow>第二个样品(ASP.NET版)
In my application, I have a requirement where if a user clicks on invoice number the generated invoice statesment is attached to a composed email in outlook. Using code below i am able to send automated emails but i need to just compose and open the outlook window for user to review and edit the contents. Do not send. Kindly help.
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);
}
not sure if this will help but how about u just create a form in tha page and allow user to type/see what they be sending. Sample here
Also Preview button can help
EDIT:
Then u need to use Microsoft.Office.Interop.Outlook namespace to create a mail item.
First sample here
From the sample, the MailItem class(oMsg) also has a Display() Method which should display the created email.
Second sample (ASP.NET version)
这篇关于撰写电子邮件与附件的前景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!