Import .msg file to outlook custom folder using c#

前端 未结 3 1571
孤街浪徒
孤街浪徒 2021-01-28 11:34

I need to add the .msg files to outlook custom folder using VSTO addin c#

3条回答
  •  不知归路
    2021-01-28 12:13

    CreateItemFromTemplate creates new items in the unsent state.

    If you want messages in the sent state, you can use either Extended MAPI (C++ or Delphi) to open the MSG file (OpenIMsgOnIStg etc.) and copy the properties into the message created in the folder (keep in mind that IMessage::CopyTo won't work since MSG files do not remap named properties correctly which can result in a corrupted message).

    If using Redemption (any language) is an option, it RDOMail object allows to set the Sent property before the message is saved for the very first time (MAPI limitation) and import an MSG file using the Import method (MSG is one of supported formats):

      set Session = CreateObject("Redemption.RDOSession")
      Session.MAPIOBJECT = Application.Session.MAPIOBJECT
      set Folder = Session.GetFolderFromID(YourOutlookFolder.EntryID)
      set Item = Folder.Items.Add("IPM.Note")
      Item.Sent = true
      Item.Import "c:\temp\test.msg", olMsg
      Item.Save
    

提交回复
热议问题