Toxter

Hello everyone,

I'm developing an Outlook 2003 addin.

I added a new button on Inspector for NewMail (File->New->Mail Message).

My button functionality involves getting "From" and "To" data and than invoke MailItem.Send() method.

However, I can't get "From" email address. I tried to get "From" field by using SenderEmailAddress property but I got only empty string.

So then, I thougt that sender email address is not set, but instead Send() method is setting that filed.

My problem is that I need to get "From" field before invoking Send().

Is this possible, and if so how

Thanks.



Re: Visual Studio Tools for Office Outlook new mail problem

Sue Mosher - Outlook MVP

Sender information is available only after the message has been transmitted to the outgoing server, i.e. after it leaves the Outbox and arrives in the Sent Items folder. You may need to rethink the logic for your application.



Re: Visual Studio Tools for Office Outlook new mail problem

Toxter

Hello Sue,

Thank you for your reply.

I was afraid that might be the case.

However, as a workaround I see next to 'Send' button in New Mail window, there is an 'Account' button.

Is it possible to get default account which is selected and to get email addres from there

Thanks.





Re: Visual Studio Tools for Office Outlook new mail problem

Sue Mosher - Outlook MVP

Only if it's Outlook 2002 or 2003 without Word as the email editor. In that narrow scenario, you should be able to get information from CommandBars. See http://www.outlookcode.com/codedetail.aspx id=889



Re: Visual Studio Tools for Office Outlook new mail problem

Toxter

Hello Sue,

Thank you for your help so far.

It is an Outlook 2003, without Word as email editor.

From that link in your last post, I am able to find an Account by it's caption.

However, what I need is to find the default Account. Is this possible

And how to get email address of that Account

Thanks.





Re: Visual Studio Tools for Office Outlook new mail problem

Sue Mosher - Outlook MVP

To get the default account, you could simply create a new message and see what its CommandBars tell you.

The Outlook object model provides no account details. You'd need the Account API (C++ or Delphi, not .NET) or Redemption to get the email address for that account. Or, hope that you pick the correct profile from the Windows Messaging Subsystem\Profiles key in the registry and hack it from the registry values.





Re: Visual Studio Tools for Office Outlook new mail problem

Mike Walker

Hi

I am keen to know what and why you are trying to gather the from details is this because of multiple account settings being used, as this is not an easy solution to get around. The other work around might be to monitor the Sent Items folder (You need to confirm this is being used) and then monitor an entry being added with your original emails content and or key to ensure the account is not being used elsewhere and then reading the From details when this is fired, this is a messy solution and probably the only non intrusive Reg Key reading method for the account settings.

Sue's command bar reader is the solution to confirm the account toolbar and as such might be sufficient for you to take as the from address. or and LDAP call to confirm the email address of the current account.

Regards