我环顾互联网,但看不到任何相关内容。我只是想在outllook中发布一个新的电子邮件,但不想发送它,因为用户可能想要将自己的东西添加到电子邮件中,我的所有程序都在添加地址和附件。
非常感谢任何帮助。
答案 0 :(得分:5)
以下是一个示例 - 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;
答案 1 :(得分:4)
您可以在outlook可执行文件上调用Process.Start。 还有用于自动填充消息的开关..
打开新邮件:
outlook.exe /c ipm.note
打开新邮件并填充发件人:
outlook.exe /c ipm.note /m someone@example.com
打开包含附件的新邮件:
outlook.exe /c ipm.note /a filename
组合:
outlook.exe /c ipm.note /m someone@example.com&subject=test%20subject&body=test%20body
答案 2 :(得分:2)
您可以使用Process.Start(“mailto:xxx”)格式。它将显示您发送邮件格式的默认电子邮件客户端。
string mailto = string.Format(
"mailto:{0}?Subject={1}&Body={2}&Attach={3}",
address,subject,body,attach);
System.Diagnostics.Process.Start(mailto)
抱歉在c#中回答。
答案 3 :(得分:1)
最简单的方法是使用Outlook COM互操作 - 只需向Outlook添加COM引用(如果已安装,则应使用主互操作程序集)
类似于:
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 = "me@example.com"
m_Message.Subject = "Subject"