New message in Outlook specifying the Sender account

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

New message in Outlook specifying the Sender account
 
Esteban Astudillo


Guest


Hi there,

Does anybody know if you can programmatically create a new message in Outlook using an account different from the default email account?

So far I've been using code like this to create new messages (and allow the user to finish editing them):


Outlook._MailItem oItem = 
 outlookApp.CreateItem(Outlook.OlItemType.olMailItem) as Outlook._MailItem;
oItem.Display(false);


This works fine, but it always uses the default Outlook account for the Sender.

Any ideas on how to specify a different account?

Thanks in advance
Esteban
Posted 15 May, 2007 16:34:39 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Esteban.

Please look at the following example:
http://www.add-in-express.com/projects/olxheaderexample.zip



P.S. Note that we take up your forum requests in the order we receive them.
Besides, it may take us some time to investigate your issue. Please be sure we will let you know as soon as the best possible solution is found.
Posted 16 May, 2007 06:28:44 Top
Esteban Astudillo


Guest


Hi Sergey,

Thank you for your sample project.

Just to clarify, this doesn't implement exactly what I was asking for. I noticed a couple of things (in case it helps somebody else):

- You set the MAPIOBJECT ?Â?Ð?ìFrom?Â?Ð?í header in the ItemSend event, but you don?Â?Ð?ét actually choose a different Outlook email account. It keeps using the Outlook account specified (directly or indirectly) by the user when composing the message.

- You can confirm this if you go to the Sent Items folder. You will see that the message was actually sent from the email account you had selected in the Accounts control at the moment of sending the message.

- The recipient, on the other hand, receives an email from the email address you specify in the ?Â?Ð?ìFrom?Â?Ð?í header on behalf of the original email address in the Accounts control. For example, if I use Account1 to send the message and in the ItemSend event I set the From header to Account2, the recipient will get an email from ?Â?Ð?ìAccount2 on behalf of Account1?Â?Ð?í.

- Finally, this doesn?Â?Ð?ét seem to work with Exchange accounts. I have an Outlook instance configured with multiple accounts one of them being an Exchange account (the default one). I tried using this technique to change the From header to a different email address but still using the default Outlook account and I got immediately an error message back saying that the Exchange server didn?Â?Ð?ét allow the operation. I would imagine that having properly configured Exchange this could be possible, but that diminishes the effectiveness of the technique.

Thank you again for your help and please let us know if you see other way to specify the actual Outlook account sending the message. I will report back here if I find a solution.

Esteban
Posted 16 May, 2007 13:48:17 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Esteban,

You set the MAPIOBJECT ?Â?Ð?ìFrom?Â?Ð?í header in the ItemSend event, but you don?Â?Ð?ét actually choose a different Outlook email account. It keeps using the Outlook account specified (directly or indirectly) by the user when composing the message.

Correct.

You can confirm this if you go to the Sent Items folder. You will see that the message was actually sent from the email account you had selected in the Accounts control at the moment of sending the message.

Correct.

The recipient, on the other hand, receives an email from the email address you specify in the ?Â?Ð?ìFrom?Â?Ð?í header on behalf of the original email address in the Accounts control. For example, if I use Account1 to send the message and in the ItemSend event I set the From header to Account2, the recipient will get an email from ?Â?Ð?ìAccount2 on behalf of Account1?Â?Ð?í.

Correct.

Finally, this doesn?Â?Ð?ét seem to work with Exchange accounts. I have an Outlook instance configured with multiple accounts one of them being an Exchange account (the default one). I tried using this technique to change the From header to a different email address but still using the default Outlook account and I got immediately an error message back saying that the Exchange server didn?Â?Ð?ét allow the operation. I would imagine that having properly configured Exchange this could be possible, but that diminishes the effectiveness of the technique

Did you set the SMTP address in the 'From' field?







Posted 17 May, 2007 06:38:31 Top
Esteban Astudillo


Guest


Hi Sergey,

Yes, I did set the SMTP email address in the From header in all the cases, including when using the Exchange account.

Now I'm curious about the purpose of your question. Would it be any different if I used the EX format of the email address for the Exchange case?

Thank you for your time.

Esteban
Posted 17 May, 2007 12:25:09 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Esteban.

The SMTP address is OK in all cases. Now I don't have another way to change the Sender account.
Posted 18 May, 2007 08:54:14 Top