如何开发Outlook加载项?

时间:2017-06-19 10:52:05

标签: email outlook office365 outlook-addin outlook-2010

我希望创建一个适用于Outlook 2010和Office 365的Outlook加载项。

我想要它做的是将MSG格式的电子邮件保存到我指定的网络文件夹中,然后将该电子邮件移动到Outlook中的存档文件夹。

我对编程知之甚少(只是基础知识)。我希望有人能指出我如何开始这个项目的正确方向以及我可以使用哪些资源来做这件事。

非常感谢任何帮助。

由于

2 个答案:

答案 0 :(得分:1)

使用VSTO创建COM插件。从https://msdn.microsoft.com/en-us/library/ms268878.aspx

开始

答案 1 :(得分:1)

有关入门的信息,请参阅Walkthrough: Creating Your First VSTO Add-In for Outlook

  

我想要它做的是将MSG格式的电子邮件保存到我指定的网络文件夹中,然后将该电子邮件移动到Outlook中的存档文件夹。

要将电子邮件保存到文件夹,您需要使用MailItem类的SaveAs方法,该方法将Microsoft Outlook项目保存到指定的路径并采用指定文件类型的格式。如果未指定文件类型,则使用MSG格式(.msg)。例如:

Sub SaveAsTXT() 
 Dim myItem As Outlook.Inspector 
 Dim objItem As Object 

 Set myItem = Application.ActiveInspector 
 If Not TypeName(myItem) = "Nothing" Then 
   Set objItem = myItem.CurrentItem 
   strname = objItem.Subject 
   'Prompt the user for confirmation 
   Dim strPrompt As String 
   strPrompt = "Are you sure you want to save the item? " &; _ 
   "If a file with the same name already exists, " &; _ 
   "it will be overwritten with this copy of the file." 
   If MsgBox(strPrompt, vbYesNo + vbQuestion) = vbYes Then 
     objItem.SaveAs Environ("HOMEPATH") &; "\My Documents\" &; strname &; ".txt", olTXT 
   End If 
 Else 
   MsgBox "There is no current active inspector." 
 End If 
End Sub

要将Outlook项目移动到另一个文件夹,您需要使用Move方法将Microsoft Outlook项目移动到新文件夹。

最后,您可能会发现Selecting an API or technology for developing solutions for Outlook文章很有帮助。它解释了扩展Outlook的可能选择。

相关问题