none
Get Outlook Meeting Invite senders SMTP email address RRS feed

  • Question

  • I am making an addin for Outlook 2013 and want to auto accept from a specific email address. Since this email is coming to the recipient from within the same domain, the OUtlook.MeetingItem .SenderEmailAddress is NOT in SMTP format. I have read the MSDN article to get the SMTP address for MailItems, but MeetingItems do not have the same properties. 

    Is there a way I can get the meeting organizer/senders SMTP address as a string?

    Thank you

    Tuesday, November 24, 2015 7:15 PM

Answers

All replies

  • Read the PR_SENDER_ENTRYID property (DASL name http://schemas.microsoft.com/mapi/proptag/0x0C190102) using MeetingItem.PropetyAccessor.GetProperty, convert the array to a hex string using MeetingItem.PropetyAccessor.BinaryToString, use the returned value to call Application.Session. GetAddressEntryFromID. Once you have AddressEntry object, call GetExchangeUser().PrimarySmtpAddress

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


    Tuesday, November 24, 2015 8:04 PM
  • Do you mean like this?

     string PR_SENDER_ENTRYID = @"http://schemas.microsoft.com/mapi/proptag/0x0C190102";

     foreach (Outlook.MeetingItem request in items)
    {

      Outlook.PropertyAccessor pa = request.PropertyAccessor;
                    byte[] sndr = pa.GetProperty(PR_SENDER_ENTRYID);
                    string sender = pa.BinaryToString(sndr);
                    Outlook.AddressEntry s = Application.Session.GetAddressEntryFromID(sender);
                    string senderEmail = s.GetExchangeUser().PrimarySmtpAddress;

    }

    senderEmail isnt coming up as any value. Thanks.

    Tuesday, November 24, 2015 9:46 PM
  • What do you see when you step through the code? Does PrimarySmtpAddress return a value?

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

    Tuesday, November 24, 2015 10:25 PM
  • No, PrimarysmtpAddress does not return a value.
    Tuesday, November 24, 2015 10:26 PM
  • So it just returns an empty string? Not an exception, just an empty string?

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

    Tuesday, November 24, 2015 10:27 PM
  • >>>No, PrimarysmtpAddress does not return a value.

    Base on your description and sample codes, I have created an addin for Outlook 2013 to try to reproduced this issue, unfortunately, I am not able to reproduce.
    These are my smaple codes, you could refer to them:

    private void button1_Click(object sender, RibbonControlEventArgs e)
    {
        Outlook.Folder folder = Globals.ThisAddIn.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox) as Outlook.Folder;
        string filter = "[MessageClass] = " + "'IPM.Schedule.Meeting.Request'";
        Outlook.Items items = folder.Items.Restrict(filter);
        string PR_SENDER_ENTRYID = @"http://schemas.microsoft.com/mapi/proptag/0x0C190102";
        foreach (Outlook.MeetingItem request in items)
        {
             Outlook.PropertyAccessor pa = request.PropertyAccessor;
             byte[] sndr = pa.GetProperty(PR_SENDER_ENTRYID);
             string snd = pa.BinaryToString(sndr);
             Outlook.AddressEntry s = Globals.ThisAddIn.Application.Session.GetAddressEntryFromID(snd);
             string senderEmail = s.GetExchangeUser().PrimarySmtpAddress;
    
             Outlook.AppointmentItem appt =request.GetAssociatedAppointment(false);
             if (appt != null)
             {
                 MessageBox.Show(appt.Subject);
             }
        }
    }
    

    For more information, click here to refer about How to: Find the Appointment Item Associated with a Meeting Request
    https://msdn.microsoft.com/en-us/library/office/ff184658.aspx

    Wednesday, November 25, 2015 5:35 AM
  • Hello Luke,

    I'd suggest using any explorer tool such as MFCMAPI or OutlookSpy for viewing low-level properties. Thus, you will be able to find the steps you need to do in the code to get the job done.

    Wednesday, November 25, 2015 7:38 AM
  • I hate to ask a question like this but I am trying to install outlookspy and I dont see it in Outlook. It definitely installed though, I see it in my installed programs in control panel...
    Wednesday, November 25, 2015 3:57 PM
  • Do you see it in File | Options | Addins?

    Did you install the version with the right bitness (32 vs 64)?


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

    Wednesday, November 25, 2015 4:06 PM
  • Dmitry, I dont see it there, only in ctrl panel > uninstall programs. I have a 64bit Windows 7 Enterprise and Outlook 2013.  I also have admin rights.
    • Edited by Luke415 Wednesday, November 25, 2015 4:20 PM
    Wednesday, November 25, 2015 4:19 PM
  • I tried installing the 32bit version and it worked. Strange though since I have 64 bit os.
    Wednesday, November 25, 2015 4:43 PM
  • The OS bitness does not matter - since OutlookSpy runs inside Outlook, it needs to match the bitness of Outlook, not the host OS.

    What do you see in OutlookSpy?


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

    Wednesday, November 25, 2015 8:32 PM
  • Luke,

    Did you have a chance to look at MFCMAPI? It is free and available with the open source code.

    Wednesday, November 25, 2015 8:43 PM
  • So this is frustrating, but I left this alone for the evening and it still wasnt returning a string. I started up the next day, no code changed in the interim, and it began returning a string for the SMTP address...
    Monday, November 30, 2015 6:30 PM
  • >>>So this is frustrating, but I left this alone for the evening and it still wasnt returning a string. I started up the next day, no code changed in the interim, and it began returning a string for the SMTP address...<<<

    According to your description, could you reproduce this issue again?

    Tuesday, December 1, 2015 9:55 AM