lihanchuan125 发表于 2015-9-13 09:21:52

OutLook编程

  public void CreateMessage()
{
   // Create a new mail item.
   Outlook.MAPIFolder outBoxfolder = this.GetNamespace("MAPI").GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderOutbox);
   Outlook.MailItem mailItem = (Outlook.MailItem)outBoxfolder.Items.Add(Outlook.OlItemType.olMailItem);
   mailItem.Subject = "Coding4Fun Sample"; //TODO: Change the Subject field of the e-mail item.
   mailItem.Body = "This email was created using VSTO 2005 Outlook support."; //TODO: Change the body of the e-mail item.
            mailItem.Attachments.Add(@"d:\aa\EULA.rtf",null,1,"aaa");
   mailItem.To = "emailaddress@emailaddress"; //TODO: Change the recipient's address.
  mailItem.Display(false); //true to make the window modal. The default value is false.
}


public void CreateTask()
{
   // Create a new task item.
   Outlook.MAPIFolder tasksFolder = this.GetNamespace("MAPI").GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderTasks);
   Outlook.TaskItem taskItem = (Outlook.TaskItem)tasksFolder.Items.Add(Outlook.OlItemType.olTaskItem);
   taskItem.Subject = "Finish Coding4Fun article!";
   taskItem.Owner = "Bob";
   taskItem.PercentComplete = 0;
   taskItem.Status = Microsoft.Office.Interop.Outlook.OlTaskStatus.olTaskInProgress;
  taskItem.Save();
}
页: [1]
查看完整版本: OutLook编程