Search code examples
emailoutlookoffice365outlook-addinoutlook-2010

How to develop a outlook add-in?


I am looking to create an add-in for outlook that works in Outlook 2010 and Office 365.

What I want it to do is Save an email in MSG format to a folder on our network, that I specify, and then move that email to an archive folder within outlook.

I don't know a lot about programming (Just the basics). I am hoping someone can point me in the right direction on how to begin this project and what resources I can use to do this.

Any help is much appreciated.

Thanks


Solution

  • See Walkthrough: Creating Your First VSTO Add-In for Outlook for getting started.

    What I want it to do is Save an email in MSG format to a folder on our network, that I specify, and then move that email to an archive folder within outlook.

    To save the email to a folder you need to use the SaveAs method of the MailItem class which saves the Microsoft Outlook item to the specified path and in the format of the specified file type. If the file type is not specified, the MSG format (.msg) is used. For example:

    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
    

    To move an Outlook item to another folder you need to use the Move method which moves a Microsoft Outlook item to a new folder.

    Finally, you may find the Selecting an API or technology for developing solutions for Outlook article helpful. It explains possible options for extending Outlook.