none
Can we read Attachment property in Transport Agent level RRS feed

  • Question

  • I am sending an attachment say Word document from Outlook to a receiver. In my TransportAgent is it possible to read the custom properties of the attachment? Right now I am able to read only the below properties, I want a property which was set by us as shown in the link https://support.office.com/en-us/article/view-or-change-the-properties-for-an-office-file-21d604c2-481e-4379-8e54-1dd4622c6b75

            public string ContentType { get; set; }
            public bool IsOleAttachment { get; }
            public AttachmentType AttachmentType { get; }
            public EmailMessage EmbeddedMessage { get; set; }
            public MimePart MimePart { get; }
            public string FileName { get; set; }
            public bool TryGetContentReadStream(out Stream result);

    Tuesday, December 18, 2018 2:31 PM

Answers

  • Hi SatishGV,

    You can read attachment property in Transport Agent level.

    Please refer to the below code:

    void YourRoutingAgent_OnSubmittedMessage(SubmittedMessageEventSource source, QueuedMessageEventArgs e)
    {
    EmailMessage emEmailMessage = e.MailItem.Message;
    foreach (Attachment atAttach in emEmailMessage.Attachments)
    {
    if (atAttach.AttachmentType == AttachmentType.Regular & atAttach.FileName != null) {
    Stream attachstream = atAttach.GetContentReadStream();
    Console.WriteLine(attachstream.Length.ToString());
    }
    }}

    For more information, please refer to this link:

    How a transport agent call tell the attachment size

    Best Regards,

    Alina


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    • Marked as answer by SatishGV Wednesday, December 26, 2018 10:31 AM
    Wednesday, December 19, 2018 2:27 AM

All replies

  • Yes you can Read custom MAPI properties in a Transport Agent.  I am not sure which version of the exchange you are using. Please have look at the below article ...

    https://gsexdev.blogspot.com/2011/04/reading-custom-mapi-properties-in.html

    Wednesday, December 19, 2018 12:47 AM
  • Hi SatishGV,

    You can read attachment property in Transport Agent level.

    Please refer to the below code:

    void YourRoutingAgent_OnSubmittedMessage(SubmittedMessageEventSource source, QueuedMessageEventArgs e)
    {
    EmailMessage emEmailMessage = e.MailItem.Message;
    foreach (Attachment atAttach in emEmailMessage.Attachments)
    {
    if (atAttach.AttachmentType == AttachmentType.Regular & atAttach.FileName != null) {
    Stream attachstream = atAttach.GetContentReadStream();
    Console.WriteLine(attachstream.Length.ToString());
    }
    }}

    For more information, please refer to this link:

    How a transport agent call tell the attachment size

    Best Regards,

    Alina


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    • Marked as answer by SatishGV Wednesday, December 26, 2018 10:31 AM
    Wednesday, December 19, 2018 2:27 AM
  • Thanks for your asking. Did you resolve your issue ? If the post helps you, you can mark it as answer and close the post. Thank you for understanding. If you have any question, or update, please feel free to let us know. I wish you a happy life!

     

    Regards,

     

    Alina


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Friday, December 21, 2018 2:22 AM
  • Thanks the link helped me to get the Mail item properties but i am looking for attachment properties
    Friday, December 21, 2018 10:06 AM
  • Alina,

    Thanks for the reply.. I am trying with this.

    Friday, December 21, 2018 10:08 AM
  • Good to know that we helped to crack down at least one item from your list :)

    Please don't forget to “mark the replies as answers if they helped, also set "like" it’s a boost for us to keep blogging J

    Friday, December 21, 2018 5:29 PM
  • Alina,

    As per the link below we added few properties

    https://wordribbon.tips.net/T012599_Creating_Custom_Document_Properties.html

    Can we read these custom properties data as well?

    Monday, December 31, 2018 12:51 PM