我看了看互联网,但看不到任何相关的东西。我只想在outllook上开始一封新邮件,但不想发送,因为用户可能希望将他们自己的内容添加到电子邮件中,而我所有的程序正在添加一个地址和附件。VB.Net电子邮件发送
任何帮助将不胜感激。
我看了看互联网,但看不到任何相关的东西。我只想在outllook上开始一封新邮件,但不想发送,因为用户可能希望将他们自己的内容添加到电子邮件中,而我所有的程序正在添加一个地址和附件。VB.Net电子邮件发送
任何帮助将不胜感激。
您可以在Outlook可执行文件上调用Process.Start。 有切换到自动填充消息以及..
打开新邮件:
outlook.exe /c ipm.note
打开一封新邮件并填写发件人:
outlook.exe /c ipm.note /m [email protected]
打开新邮件带附件的消息:
outlook.exe /c ipm.note /a filename
组合:
outlook.exe /c ipm.note /m [email protected]&subject=test%20subject&body=test%20body
下面是一个例子 - http://support.microsoft.com/kb/310263
// Create the Outlook application by using inline initialization.
Outlook.Application oApp = new Outlook.Application();
//Create the new message by using the simplest approach.
Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
//Add a recipient.
// TODO: Change the following recipient where appropriate.
Outlook.Recipient oRecip = (Outlook.Recipient)oMsg.Recipients.Add("e-mail address");
oRecip.Resolve();
//Set the basic properties.
oMsg.Subject = "This is the subject of the test message";
oMsg.Body = "This is the text in the message.";
//Add an attachment.
// TODO: change file path where appropriate
String sSource = "C:\\setupxlg.txt";
String sDisplayName = "MyFirstAttachment";
int iPosition = (int)oMsg.Body.Length + 1;
int iAttachType = (int)Outlook.OlAttachmentType.olByValue;
Outlook.Attachment oAttach = oMsg.Attachments.Add(sSource,iAttachType,iPosition,sDisplayName);
// If you want to, display the message.
// oMsg.Display(true); //modal
//Send the message.
oMsg.Save();
oMsg.Send();
//Explicitly release objects.
oRecip = null;
oAttach = null;
oMsg = null;
oApp = null;
这种方法非常好,只需要包含VSTO组件的一个缺点。 – Jirapong 2009-09-09 11:39:57
可以使用的Process.Start( “电子邮件地址:XXX”)格式。它会调出默认的邮件客户端格式,你把它寄到。
string mailto = string.Format(
"mailto:{0}?Subject={1}&Body={2}&Attach={3}",
address,subject,body,attach);
System.Diagnostics.Process.Start(mailto)
对不起,在C#中回答。
要做到这一点,最简单的方法是使用Outlook COM互操作 - 只需添加一个COM引用到Outlook(如果已安装它应该使用主Interop大会)
因此,像:
Dim m_Email As New Microsoft.Office.Interop.Outlook.ApplicationClass
dim m_Message As Microsoft.Office.Interop.Outlook.MailItem = m_Email.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)
m_Message.To = "[email protected]"
m_Message.Subject = "Subject"
非常感谢您的帮助。我植入了一些建议,并使用com包装器工作。我还记得我有一些旧代码在一个非常旧的版本库中执行过。再一次感谢你。 – 2009-09-09 12:21:56