Getting Senders email

Add-in Express™ Support Service
That's what is more important than anything else

Getting Senders email
SendersEmailAddress property 
Spiros Nikolopoulos


Guest


Hi,
I'm using the code below to get details from a selected Mail in Outlook 2010.
My problem is that I can't find the SendersEmailAddress as a property of the MailItem


    if Assigned(IExplorer) then
      try
        try
          ISelection := IExplorer.Selection;
        except
          ISelection := nil;
          //skip an exception generated by Outlook when some
          //folders are selected
        end;

        if Assigned(ISelection) then
          try
            if ISelection.Count > 0 then
             begin
                Result :=  OleVariant(ISelection.Item(1)).Subject;
                Body   :=  OleVariant(ISelection.Item(1)).Body;
                HTMLBody   :=  OleVariant(ISelection.Item(1)).HTMLBody;
                iFrom := MailItem (ISelection.Item(1) ).SenderName;
                iMail := MailItem (ISelection.Item(1) );

                if (MailItem (ISelection.Item(1) ).Recipients.Count > 0) then begin
                   eMailAdd := MailItem (ISelection.Item(1)).Recipients.Item(1).Address;
                end;

               if not MailItem( ISelection.Item(1) ).Saved then
                    MailItem ( ISelection.Item(1) ).Save;

                saveAttachments( MailItem (ISelection.Item(1) ) );

             end;
          finally
            ISelection := nil;
          end;
      finally
        IExplorer := nil;
      end

Posted 05 Jan, 2012 04:52:13 Top
Andrei Smolin


Add-in Express team


Posts: 18823
Joined: 2006-05-11
Hi Spiros,

The issue occurs because Add-in Express bases on Office 2000 wrappers and MailItem.SenderEmailAddress was introduced in Outlook 2003. That is, in your code you need to make sure that the Outlook version is 2003 or higher and invoke that property via late binding (OleVariant).


Andrei Smolin
Add-in Express Team Leader
Posted 05 Jan, 2012 05:15:37 Top
Spiros Nikolopoulos


Guest


Hi,
Thanks or you reply.Is possible to give me an example of that?
Thanks
Posted 05 Jan, 2012 05:37:58 Top
Andrei Smolin


Add-in Express team


Posts: 18823
Joined: 2006-05-11
Have a look at http://www.add-in-express.com/forum/read.php?FID=1&TID=1226.


Andrei Smolin
Add-in Express Team Leader
Posted 05 Jan, 2012 05:47:32 Top
Spiros Nikolopoulos


Guest


OK I've got it now

Thanks Andrei.
Posted 05 Jan, 2012 06:22:41 Top