• Subject: Outlook automation - SendUsingAccount readonly?
  • Author: Pavel Celba
  • Date: 31 Mar 2010
  • References:
Hi experts,

I am trying to change the default Outlook account but it seems to be
readonly for new mail messages... Does somebody know the solution?

My code (Visual FoxPro):
oOutlook = CREATEOBJECT("Outlook.Application")
oNamespace = oOutlook.GetNameSpace("MAPI")
oNamespace.Logon()
loItem = oOutlook.CreateItem(0)
loitem.To = 'some@email.com'
loitem.Body = "BODY"

*-- Here is the problem
loitem.SendUsingAccount = oOutlook.Session.Accounts.Item[2] && I am sure
this is valid POP3 account

*-- Account should be changed now BUT
? loitem.SendUsingAccount && Still returns null (it is not an object)

Note: If I would send the message now, it will use default account

*-- After issuing
loitem.Display
*-- and changing Account manually via UI everything works as it should -
means the SendUsingAccount property is no more Readonly and I can assign
different accounts via automation commands...

So, the question is: How to create mail item having the SendUsingAccount
property R/W using automation?

I'll test above code in VB.NET to avoid VFP interoperability problem.

TIA for answers!

Outlook version: 2007 SP2 (12.0.6514.5000)
OS version: Vista Business SP2
31 Mar 2010Outlook automation - SendUsingAccount readonly?.Pavel Celba
31 Mar 2010|- Re: Outlook automation - SendUsingAccount readonly?.Ken Slovak - [MVP - O...
01 Apr 2010|  \ Re: Outlook automation - SendUsingAccount readonly?.Pavel Celba
01 Apr 2010|     \ Re: Outlook automation - SendUsingAccount readonly?.Ken Slovak - [MVP - O...
31 Mar 2010\ Outlook automation - SendUsingAccount readonly.Miguel Santos
01 Apr 2010   \ Re: Outlook automation - SendUsingAccount readonly.Pavel Celba
Contact Us
All times are in (US) Eastern Daylight Time (GMT -4:00)