How do I set the To address in a mailitem

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

How do I set the To address in a mailitem
 
Julian Pointer


Guest


How do I set the "To" address in a mailitem, this is my code below... The code works, I just cant see the email adress in the "to" box. If I send the email it works.


procedure TAddInModule.DoNewInspector(ASender: TObject; const Inspector: _Inspector);
var
IMail : MailItem;
Insp : TInspector;
begin

//New Mail Item
IMail := nil;
if Assigned(Inspector) and Assigned(Inspector.CurrentItem) then
Inspector.CurrentItem.QueryInterface(IID__MailItem, IMail);

if Assigned(IMail) then
begin

showmessage('here');
if FileEmail(IMail) then
begin

if length(trim(gsEmailTo)) > 0 then
IMail.To_ := gsEmailTo;
end
else
CloseInspector(Inspector);
end;
Posted 17 May, 2005 18:38:06 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Julian,

Try to operate with the Recipients collection of the _MailItem interface instead of changing the To_ property.

Posted 18 May, 2005 06:28:07 Top
Julian Pointer


Guest


Didn't work... ? I added an email to the recipients collection
Posted 20 May, 2005 07:33:20 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Julian,

I am afraid in this case you will have to reopen the mail item to see the changes you have made programmatically.

Posted 20 May, 2005 11:28:48 Top
Myles Wakeham


Guest


Out of interest, does the Recipients collection also control the 'From' address? I'm trying to find out how to get access to a Mail Item's From address (the email address, not the Sender Name). Where does one get this information from?

Myles
Posted 20 May, 2005 11:41:43 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Myles,

No, the Recipients collection doesn't contain a sender email address. The SenderName, SenderEmailType and SenderEmailAddress properties are available in Outlook 2003 Object Model. In earlier versions of Outlook they can be accessed via Extended MAPI or CDO.

Posted 20 May, 2005 11:55:32 Top
Myles Wakeham


Guest


Thank you for the tip. Do you have any (or know of any) sample code in Delphi that will demonstrate how to access Extended MAPI or CDO?

Myles
Posted 23 May, 2005 10:13:12 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Myles,

We provide such code samples to our Premium Subscribers.

Posted 24 May, 2005 07:05:28 Top