none
Need to get MailItem owner email id(The account by which mail item downloaded in Outlook) using vb.net RRS feed

  • Question

  • Type: critical issue

     

    Environment:

    OS : - Windows 7 64 bit

    IDE : - Visual Studio 2008

    Word: MS Office 2007

    Language : - VB .net

      

    Project type : - File-->New Project --> Others Project Types -->Extensibility --> Shared Add-in

    .

     

    Problem Description: We have AddIns program, which runs on Outlook and works perfectly. Recently, we have received a requirement from client to fetch owner email id of the mail item i.e. “The account by which mail item downloaded in Outlook”.

    .

    Kindly assist us, how can we achieve this.

    .

    I will be thankful.



    Regards, S.P Singh

    Thursday, April 6, 2017 6:35 AM

Answers

  • I have tried the following snippet and it is giving desired output, kindly suggest, if below code is fine.

    Dim sessionUserMailId As String
    
    sessionUserMailId = New Microsoft.Office.Interop.Outlook.Application().ActiveExplorer.Session.CurrentUser.Address



    Regards, S.P Singh

    Thursday, April 6, 2017 4:28 PM

All replies

  • Hello Singh,

    The Account class from the Outlook object model class provides the DeliveryStore property which returns a Store object that represents the default delivery store for the account. You can compare the parent store of the Outlook item and the delivery store for the account. That way you can find an account which was used for downloading the item.

    The SmtpAddress property of the Account class returns a string representing the Simple Mail Transfer Protocol (SMTP) address for the Account. The purpose of SmtpAddress and Account.UserName is to provide an account-based context to determine identity.


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

    Thursday, April 6, 2017 1:29 PM
  • I have tried the following snippet and it is giving desired output, kindly suggest, if below code is fine.

    Dim sessionUserMailId As String
    
    sessionUserMailId = New Microsoft.Office.Interop.Outlook.Application().ActiveExplorer.Session.CurrentUser.Address



    Regards, S.P Singh

    Thursday, April 6, 2017 4:28 PM
  • Hello,

    I suggest you mark helpful post or your solution as answer to close the thread if your issue has been resolved. Thanks for your understanding.

    Regards,

    Celeste


    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. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, April 10, 2017 5:58 AM
    Moderator
  • it returns default account address in case of multiple accounts signed in to outlook.
    Thursday, April 19, 2018 3:35 PM
  • Use the SendUsingAccount property to get the right account. It returns an Account object that represents the account under which the MailItem is to be sent.

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

    Monday, April 23, 2018 11:32 AM