我环顾互联网,但看不到任何相关内容.我只是想在outllook中开始一个新的电子邮件,但不想发送它,因为用户可能想要将自己的东西添加到电子邮件中,我的所有程序正在做的是添加地址和附件.
任何帮助将不胜感激.
这是一个示例 - 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;
Run Code Online (Sandbox Code Playgroud)