Setting account for an outgoing email

G

Guest

I am using OLE to call outlook in my app to send email. I see many
properties I can set, but not one that I can use to set the account (e.g.,
send via (e-mail address removed), or send via (e-mail address removed), etc.) that will be used
to send the email. I have 2 accounts set up in outlook now that I could
access.

Can anyone help on how outlook sets this account and how I would do it
programmatically before I send the email?

Many thanks for any ideas on this,
Mark
 
D

Dmitry Streblechenko

1. OOM in Outlook 2007 - MailItem.SendUsingAccount property
2. Extended MAPI (C++/Delphi only) - use IOlkAccountMgr to read the account
names/ids and set them on the message (look at a message with an account
info set using OutlookSpy - click IMessage)
3. <plug> RDOMail.Account property - see
http://www.dimastr.com/redemption/rdo/RDOMail.htm </plug>

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
J

JHoep

Following along this logic, is there a way to use MailItem.SendUsingAccount
that will attempt to send the email via one account, but if that fails, to
use a second account that is set up in Outlook?
I currently have two accounts, one which works when I have my laptop at work
(through one SMTP server) and one which works at home (through a different
SMTP server). I am trying to avoid having to manually select the account
every time I am at the non-default account location.
Thanks for any assistance you can provide.
Jason
 
S

SvenC

HI JHoep,
Following along this logic, is there a way to use
MailItem.SendUsingAccount that will attempt to send the email via one
account, but if that fails, to use a second account that is set up in
Outlook?

I guess the problem is that using the wrong account does not result
in a failure but will just keep the mail in the outbox until the smtp server
gets available, correct?
I currently have two accounts, one which works when I have my laptop
at work (through one SMTP server) and one which works at home
(through a different SMTP server). I am trying to avoid having to
manually select the account every time I am at the non-default
account location.

You might need to check the availability of some other resource, e.g.
a file on a network share which is only available when you are in your
work network. That should help to figure out which account to use.
 
J

JHoep

Ok, I definitely can check for the existence of a network drive or other
shared file that would be accessible only at work. But how do I do that?
What would be the basic commands/syntax to have Outlook do the check and then
pick the account to send the email from (ideally this happens behind the
scenes when the "Send" button is pressed).
Thanks.
Jason
 
S

SvenC

Hi JHoep,
Ok, I definitely can check for the existence of a network drive or
other shared file that would be accessible only at work. But how do
I do that? What would be the basic commands/syntax to have Outlook do
the check and then pick the account to send the email from (ideally
this happens behind the scenes when the "Send" button is pressed).

I thought you wanted to do some macro programming.

When you want Outlook to automatically choose the accout you could
add some code in the ItemSend event of Outlook.Application. I am not
sure if you can change the account at this point but you can at least try
it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top