none
Problems when adding Cloudy Attachments (ATTACH_BY_WEBREFERENCE - 7) RRS feed

  • Question

  • Problems when adding Cloudy Attachments (ATTACH_BY_WEBREFERENCE - 7)

    The goal: Using a VSTO C# addin, programmatically add a cloudy attachment trying to mimic the same results than Outlook. This action is done each time an item is sent (in the outbox folder)

    The code:

    Outlook.Attachment newAtt = mail.Attachments.Add(szAnonymousLinkPath, 7/*ATTACH_BY_WEBREFERENCE*/, 1, szAttachmentName);

    Here szAnonymousLinkPath (string data type) points to an anonymous link in Office 365. It is something like:

    https://my365TEST-my.SPServer.com/:w:/g/personal/user_my365TEST_onmicrosoft_com/EVqpvwDqT0pImIRmMluAu7kBGUqQdyMF9I2uoPOltArh6w

    The goal of having an anonymous link is that using this link everyone can directly access it without having to login. It’s a way to share your document with an anonymous person.

    The real link is different, it is something like:
    https:// my365TEST-my.SPServer.com/personal/user_fortest365_my365TEST_com/Documents/Attachments/file.docx

    But the real link cannot be used in Attachments.Add since else only users that are logged in will be able to access to that link.

    The szAttachmentName parameter is the file name (string value) and in this case it can be for example “file.docx”.

    The problem: Basically talking it works… A cloudy attachment is added. However if you then click on Forward or on Open Location (right click menu in the cloudy attachment), then these actions will not work because Outlook does not have the real link.

    The solution: I discovered there is a MAPI property in the Attachment object that is:

    Tag: 0x848C001E

    Type: PT_STRING8

    DASL: http://schemas.microsoft.com/mapi/string/{96357F7F-59E1-47D0-99A7-46515C183B54}/AttachmentOriginalUrl

    Named Prop Name: AttachmentOriginalUrl

    Named Prop Guid: {96357F7F-59E1-47D0-99A7-46515C183B54} = PSETID_Attachment

    In my case this property (I use MFCMAPI) contained the anonymized link (e.g. https://my365TEST-my.SPServer.com/:w:/g/personal/user_my365TEST_onmicrosoft_com/EVqpvwDqT0pImIRmMluAu7kBGUqQdyMF9I2uoPOltArh6w).
    If I manually modify this property and replace it with the real link (e.g. https:// my365TEST-my.SPServer.com/personal/user_fortest365_my365TEST_com/Documents/Attachments/file.docx) in the sent item, then it does the trick and you can forward or do open location.

    So here I first tried to use Outlook Object Model, but for any reason I cannot do it. I try:

    object oGot = newAtt.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x848C001E");

    but it gives an exception saying the property does not exist. I try using other values like:

    http://schemas.microsoft.com/mapi/string/{96357F7F-59E1-47D0-99A7-46515C183B54}/AttachmentOriginalUrl

    Or

    http://schemas.microsoft.com/id/string/{96357F7F-59E1-47D0-99A7-46515C183B54}/0x848C001E

    But it is the same.

    I use Redemption:

    Redemption.RDOSession session = new Redemption.RDOSession();

    Redemption.RDOMail msg = (Redemption.RDOMail)session.GetRDOObjectFromOutlookObject(mail);

    Outlook.Attachment newAtt = mail.Attachments.Add(szAnonymousLinkPath, 7/*ATTACH_BY_WEBREFERENCE*/, 1, szAttachmentName);
    newAtt.DisplayName = szAttachmentName;
    mail.Save();
    foreach (Redemption.RDOAttachment red_att in msg.Attachments) {
      if (red_att.DisplayName == newAtt.DisplayName) {

    red_att.FileName = newAtt.DisplayName;

    red_att.set_Fields("http://schemas.microsoft.com/mapi/proptag/0x848C001E", szRealURLPath);

                  red_att.Save();

       }

    }

    And by this way in one of my computers it works. However in other 2 computers it does not work… there is no exception but it’s like if the red_att.set_Fields does not work. In one of the computer having the issue, calling red_att.get_Fields works by returning the anonymized link but when calling set_fields it’s like if nothing is done. In the other computer red_att.get_Fields returns null.

    Using MFCMAPI I can see the property exists in the item that is in the outbox folder… so I wonder why redemption does not behave OK.

    Is there any way to either:

    1+ Call mail.Attachments.Add in a way where I can both specify the anonymized link plus the real link (there is no documentation about how to deal with Cloudy attachments in internet)

    2+ Without using Redemption (but using Outlook Object Mode) modify this AttachmentOriginalUrl property.

    3+ Using Redemption modify this property.

    Thanks in advance

    Wednesday, April 25, 2018 6:23 PM

All replies

  • Hello Pablo,

    Great findings!

    But I'd suggest opening a support case with Microsoft for that. I don't think forum readers can help with this problem. Only insiders/developers can shed any light for that.

    Please don't forget to share the solution here, of course, if you find any.


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Wednesday, April 25, 2018 6:56 PM
  • When setting the property using Redemption, do not hardcode the named property proptag. Use “http://schemas.microsoft.com/mapi/string/{96357F7F-59E1-47D0-99A7-46515C183B54}/AttachmentOriginalUrl

    I do not know why OOM won't work...


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Wednesday, April 25, 2018 7:52 PM