none
Adding a recipient to the .msg file RRS feed

  • Question

  • Hello!

    I've a task to develop an utility that could write an msg file from scratch without using any mapi libraries. This limitation is strict, unfortunately.

    So I've studied the structure of the compound file, the red-black trees, etc.

    Now I'm trying to make a file with a message. I can manage every stream and storage like __properties_version1.0, recipient storages and add data to them. I can build a draft message file without any recipients. What I need to do is to "attach" a node to this streams tree that would be a storage for the recipient. I can make a small 7 node storage with needed streams like __recip_version1.0_#0000000, streams that store PidTagEntryId, PidTagDisplayName and so on. Moreiver, I set the value of the top-level stream that is responsible for the DisplayTo form. However, when I open the file and move the mouse to the email address in the "To:" form, the recipient's email disappears. I suppose that I've missed something when I was adding the recipient container (a red-black tree with 7 nodes) to the global tree.

    I'd like to find out what actions should be made when the recipient is added to the message.
    I've already contacted Dmitry Streblechenko from Microsoft whose comments on the net about outlook technologies are very useful, but he had no idea.

    Tuesday, March 31, 2009 9:26 AM

Answers

  • Mx,

    Which reference are you utilizing in regards to the following directory entry type:

    --> STGTY_INVALID = 0x0

    entry.Type = SID_Type.STGTY_INVALID;

    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

    Upon reviewing the latest version of MS-CFB on the Open Specifications site (http://msdn.microsoft.com/en-us/library/dd942138(PROT.10).aspx), you will see the following Object Types (1 byte):

    Unknown or unallocated = 0x00
    Storage Object = 0x01
    Stream Object = 0x02
    Root Storage Object = 0x05

    The directory entry type you indicate is either of an unknown type or unallocated per Section 2.6.1 "Compound File Directory Entry" of MS-CFB on Page 24.

    Does this information assist you?

    Dominic Salemno
    Senior Support Escalation Engineer

    Friday, July 31, 2009 2:22 PM
  • Hi lidas,

    For PidTagEntryId, it depends on how the EntryId is used.  EntryIds are used in different ways and can be of different lengths.  They are all binary types.  [MS-OXCDATA] 2.2.4.1 describes and example of the Folder EntryID.  As you can see in [MS-OXCDATA] 2.2.3 (General EntryID Structure), the first two fields are 4 bytes of flags and a 16 byte provider UID, which takes different forms depending on it's use, and then provider specific data described in subsequent sections like 2.2.4.1 mentioned above. 

    For PidTagRecipientEntryId, there are examples and the property is listed correctly in [MS-OXPROPS].  Did you need more information on that property?

    Best regards,
    Tom Jebo
    Escalation Engineer
    Microsoft Open Specifications

     

    Sunday, October 2, 2011 4:20 AM
    Moderator
  • Hi, Tom.

    Thank you for your prompt response.

    I find out that to create recipient in msg enough:

    -PR_ADDTYPE  0x3002

    -PR_RECIPIENT_TYPE 0x0C15

    -PR_DISPLAY_NAME 0x3001 string format is "DisplayName <Email>"

    -property with ID 0x3000. This is recipient number

    It works for me.

    Sunday, October 2, 2011 9:03 PM

All replies

  • Hi Mx,

    I will have to debug this one to track down why it does not work.  Can you please upload the .msg file to
    https://sftus.one.microsoft.com/ChooseTransfer.aspx?key=269d88c6-9811-4edf-9639-5d055d42cd9b

    Password: kC{kz)]xr]*

    Thanks!


    Developer Consultant
    Tuesday, March 31, 2009 6:16 PM
    Moderator
  • Hi Tom,
    I've sent you my .msg file! Thanks for help
    Wednesday, April 1, 2009 11:53 AM
  • I got the file.  Thanks!
    Developer Consultant
    Wednesday, April 1, 2009 5:22 PM
    Moderator
  • I've found the problem and the solution. The thing was that I wrote two different pices of data into the RecipientType field. I was confused by the MS-OXOMSG document where it is said that this field: "Represents the recipient type of a recipient on the message. This property MUST be set on each recipient. The format of this property is listed in the following " (then go the Originator, the Primary Recipient, Cc and Bcc). But "the flags in the following table can be combined with the values listed in the previous table. " and then two more flags go.
    So these additional flags must have not been set
    Monday, April 6, 2009 9:14 AM
  • Unfortunately, if I add a large attachment and the overall .msg file size is over 109*128*512 = 6.9 megabytes, the attachment is unreadable. Maybe there is something wrong with the DIF structure.
    Tom, may I send you the new version of my file? Could you take a look at it?
    Monday, April 6, 2009 10:18 AM
  • Please upload the file to the location I mentioned above.  I have a lot of open customer questions I'm working on so my first chance to look at this will be Thursday.


    Developer Consultant
    Monday, April 6, 2009 9:59 PM
    Moderator
  • Oh, I've managed to find the mistake.
    It seems that now everything works fine! I couldn't imagine it is possible to do such a thing without the usage of any MAPI stuff...

    Tuesday, April 7, 2009 8:08 AM
  • Thanks for the update. 

    What things should be included in the protocol documentation that would have better helped you?


    Developer Consultant
    Tuesday, April 7, 2009 6:23 PM
    Moderator
  • Well, I was confused by the lack of examples of the red-black tree in the .msg file. The documentation on compound files is OK, but an example of a valid tree of streams from a .msg file would be great. I guess that's the trickiest point in my task.
    Then, the order of information in the file. For some reason after opening my file Outlook changes the order of some sectors in FAT and DIF structures. Maybe due to the wrong order of data in the file it cannot be edited in Outlook (an error occurs - "The message interface has returned an unknown error. If the problems persists, restart Outlook"). I'm happy that this error is not important now!
    And, of course, the trick with the RecipientType field, which I described a few posts earlier, was REALLY embarrasing. I think that it should be mentioned that some flags must not be set in .msg files since they are of no use for Outlook. It was sad to discover that just one bit in the whole file ruined everything
    Wednesday, April 8, 2009 1:43 PM
  • Damn, Outlook 2007 does not want to open it... Tom, I am terribly sorry for asking you again to take a look at the file. Can you give me a new password? Seems the battle is not over yet=(
    Thursday, April 9, 2009 3:24 PM
  • Here is a new workspace to upload the file to:

    https://sftus.one.microsoft.com/choosetransfer.aspx?key=ddf77ad9-6d4e-4e66-9714-df12dc472b1f

    Password: s1$lUAXk9mg%

     


    Developer Consultant
    Friday, April 10, 2009 4:49 AM
    Moderator
  • have sent it, thanks
    Friday, April 10, 2009 9:24 AM
  • It seems that Outlook 2007 adds streams that are of STGTY_INVALID = 0x0 type. My code generation class parsed the correct file and the output was

    entry = new DirectoryEntry();
    entry.Type = SID_Type.STGTY_INVALID;
    entry.GUID = new byte[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    entry.Name = ""; /**/
    entry.Color = SID_Color.DE_BLACK;
    entry.SID = (uint)17;
    entry.LeftChildSID = (uint)SectInfo.FREESECT;
    entry.RightChildSID = (uint)SectInfo.FREESECT;
    entry.RootChildSID = (uint)SectInfo.FREESECT;

    maybe it fills free space within the Directory sectors with such streams
    Friday, April 10, 2009 11:51 AM
  • I got the uploaded file sub_u.msg and I got feedback from Outlook development today that should help me better scope this.
    Developer Consultant
    Saturday, April 11, 2009 1:45 AM
    Moderator
  • So, Tom, is there any update?
    Monday, April 20, 2009 8:32 AM
  • Hi,

    Even I have a task to develop an library that could write an msg files from scratch without using any mapi libraries. Could you please guide how to do this? It will be greatly helpful if you can provide some sample in C#.

    Thanks,

    Amir
    Wednesday, April 22, 2009 7:48 AM
  • I am talking to the Outlook developer support team to help me out as it's not clear to me why it is not working.
    Developer Consultant
    Thursday, April 23, 2009 4:44 AM
    Moderator
  • Tom, thank you very much, I really hope the support team members will find what's wrong. I don't know why Outlook 2007 does not open any message file.
    Amir, it is a great volume of work. What you need to do first is to read documentation on how compound files are organized (like MS-CFB http://msdn.microsoft.com/en-us/library/cc546605.aspx). Then after you implement all these FAT, DIF, MiniFAT, Ministream, Directory and other stuff, you switch to MS-OXMSG (http://msdn.microsoft.com/en-us/library/cc463912.aspx) and learn the pecularities of .msg files like Nameid storage, properties stream, etc.
    Download this library I found on the net - http://ifolder.ru/11770665. It will help you to understand the basics of the compound file
    My method of work was based on using this library. I made classes that encapsulate the functionality of compound file elements like DirectoryEntry or FAT. Then I wrote a bit more code in this library so that I could pass the path to an existing .msg file made by Outlook and the library would parse it and make a .txt file with a large C# method inside that builds the same structure of the initial file using my classes.
    Anyway, that's a very time-consuming task
    Thursday, April 23, 2009 11:01 AM
  • Hi,

    Thank you very much. 

    Your guidance are really helped alot. One more help, Is it possible tell me how long it took approximately for you, Please.

    Thank You!!!

    Thanks,

    Amir

    Tuesday, May 5, 2009 6:39 AM
  • Sorry I am still waiting on a response from development.   

    I did talk to someone on the Developer Support Messaging team he suggested that you use Outlook to craft a similar message and save it to MSG format and then use DocFile Viewer to see an example of what the protocol document’s output should be and then change your code as needed.  He said that this is the best way to get something working against the .msg file format.


    Developer Consultant
    Thursday, May 7, 2009 5:17 AM
    Moderator
  • Mx,

    I am the engineer who has taken ownership of your case. I am investigating your issue and will update you as things progress.

    Dominic Salemno
    Senior Support Escalation Engineer

    Thursday, May 14, 2009 4:41 PM
  • Mx,

    Could you send me your sample files to dochelp@microsoft.com?

    Dominic Salemno
    Senior Support Escalation Engineer
    Monday, May 18, 2009 1:12 PM
  • Mx,

    I do not have insufficient information to proceed. In the meantime, the information regarding this issue will be archived.

    Dominic Salemno
    Senior Support Escalation Engineer
    Tuesday, June 16, 2009 3:40 PM
  • Mx,

    I am still investigating this issue. I will update this thread as things progress.

    Dominic Salemno
    Senior Support Escalation Engineer
    Wednesday, July 29, 2009 5:04 PM
  • Mx,

    Which reference are you utilizing in regards to the following directory entry type:

    --> STGTY_INVALID = 0x0

    entry.Type = SID_Type.STGTY_INVALID;

    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

    Upon reviewing the latest version of MS-CFB on the Open Specifications site (http://msdn.microsoft.com/en-us/library/dd942138(PROT.10).aspx), you will see the following Object Types (1 byte):

    Unknown or unallocated = 0x00
    Storage Object = 0x01
    Stream Object = 0x02
    Root Storage Object = 0x05

    The directory entry type you indicate is either of an unknown type or unallocated per Section 2.6.1 "Compound File Directory Entry" of MS-CFB on Page 24.

    Does this information assist you?

    Dominic Salemno
    Senior Support Escalation Engineer

    Friday, July 31, 2009 2:22 PM
  • sorry guys for not responding to your posts, I was away for a long time... Dominic, thanks for your assistance, but I'm afraid our customer didn't like our project, so there is nothing to worry about now. As I remember, I didn't find out why Outlook 2007 makes such STGTY_INVALID entries, so I just made them too and it worked. I was just curious why these entries are needed by Outlook 2007. Nevertheless, it is over now =) Thanks for you post, anyway
    Thursday, August 27, 2009 3:50 PM
  • I try to write the same utill. Please, can you tell me about PidTagEntryId and PidRecipientEntryId properties. Whate kind of structure these propeties have. I read much documentation, but don't find any description.

    What properties (streams) is requried  in recipient storage ?

    Thank you in advanced!

    Thursday, September 29, 2011 10:04 PM
  • Hi lidas,

    Thanks for your question about PidTagEntryId and PidRecipientEntryId.  One of the Open Specifications team will respond shortly to assist you.

    Best regards,
    Tom Jebo
    Escalation Engineer
    Microsoft Open Specifications

    Friday, September 30, 2011 8:12 PM
    Moderator
  • Hi lidas,

    For PidTagEntryId, it depends on how the EntryId is used.  EntryIds are used in different ways and can be of different lengths.  They are all binary types.  [MS-OXCDATA] 2.2.4.1 describes and example of the Folder EntryID.  As you can see in [MS-OXCDATA] 2.2.3 (General EntryID Structure), the first two fields are 4 bytes of flags and a 16 byte provider UID, which takes different forms depending on it's use, and then provider specific data described in subsequent sections like 2.2.4.1 mentioned above. 

    For PidTagRecipientEntryId, there are examples and the property is listed correctly in [MS-OXPROPS].  Did you need more information on that property?

    Best regards,
    Tom Jebo
    Escalation Engineer
    Microsoft Open Specifications

     

    Sunday, October 2, 2011 4:20 AM
    Moderator
  • Hi, Tom.

    Thank you for your prompt response.

    I find out that to create recipient in msg enough:

    -PR_ADDTYPE  0x3002

    -PR_RECIPIENT_TYPE 0x0C15

    -PR_DISPLAY_NAME 0x3001 string format is "DisplayName <Email>"

    -property with ID 0x3000. This is recipient number

    It works for me.

    Sunday, October 2, 2011 9:03 PM
  • Hi lidas,

    Glad to hear you have what you need. 

    Tom

    Monday, October 3, 2011 3:06 AM
    Moderator
  • Dear Mx,

    Could you kindly show us your code for add recipients to msg file? I can not fix this problem for long time. I don't know how to update _properties_version1.0. my mailbox is chensg@live . com Many thanks!


    Sunday, May 10, 2015 4:33 PM
  • Hello Shogun chen,
    If you would like assistance from Microsoft Open specifications team, please let us know. You could start a separate a thread with details of your question and include a reference to existing thread if needed.    

    Regards,
    Sreekanth Nadendla
    Microsoft Windows Open Specifications
    Monday, May 11, 2015 6:10 PM
    Moderator