Selecting Outlook Profile in Code

  • Thread starter Thread starter Kate
  • Start date Start date
K

Kate

I am sending emails through an Access Application and I want to use a
specific profile to send those emails. I would like to avoid having my users
pick a profile every day. To that end...is there a way that I can specify
the profile to use when I create my Outlook Object. I see the Read Only
CurrentProfile for the namespace object and DefaultProfile for the
Application Object...but can not figure how to call an existing profile and
use it to send the emails.

I had wanted to use the 'SendUsingAccount' property of the Mail Item but I
am unable to add another Exchange Account to my existing profile. I am not
sure if that is the way my organization has it structured or if that is an
inherent restriction of Outlook 2007 or Exchange.

Any suggestions, KB references or code samples would be appreciated?

Thanks,
Kate
 
Are you trying to send from another Exchange account? Use the
MailItem.SentOnBehalfOfName property.

If Outlook is already running, you can't start another session with another
profile. If it's not running, you can specify a profile with a
Namespace.Logon statement.
 
Thank you, Sue.

Yes...I do want to send from another Exchange account (Jobs)...it is an
account created as a correspondence tool for HR...sending and receiving
emails from job applicants.

I first thought that using the SentOnBehalfOfName property would work well
for us...but, unless I am doing something wrong...the Sent Items are stored
in the Sent Items folder of the user logged into the Access app. Since these
emails are documents of record for corresponding with applicants, I need them
to reside in the Jobs folders.

I started looking at using the SendUsingAccount property and can not make
that work because I can only have one exchange account. Next...I created a
profile that uses the Jobs account called it 'Recruitment'. I tried the
Namespace.Logon as suggested...
objOutlookNameSpace.Logon "Recruitment", , False, True
I get no errors, the email sends just fine, but the profile and the return
address are my account not Jobs.

I appreciate your help. We just migrated from GroupWise so I am under the
gun to get my code rewritten to address the Outlook object.
 
You could use the Folder.Items.ItemAdd event to monitor the Sent Items folder
for new items and move those sent on behalf of the Jobs mailbox to its Sent
Items folder.

Otherwise, you'll need to get the third-party Redemption library from
http://www.dimastr.com/redemption/. It provides the ability to log onto a
session with an Exchange mailbox, parallel to the current Outlook session,
and send messages from that mailbox.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 
Thank you very much for your help. I might have to come back and ask for
help on moving mail items from one account to another :).
 
Back
Top