troubleshooting Question

Outlook automation - SendUsingAccount readonly in VFP...?

Avatar of Pavel Celba
Pavel CelbaFlag for Czechia asked on
17 Comments1 Solution3501 ViewsLast Modified:
I am trying to change the default Outlook account from VFP via automation but it seems to be readonly for new mail messages... Does somebody know the solution?

My code:
oOutlook = CREATEOBJECT("Outlook.Application")
oNamespace = oOutlook.GetNameSpace("MAPI")
loItem = oOutlook.CreateItem(0)
loitem.To = ''
loitem.Body = "BODY"

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

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

loItem.Send()  && sends the message to default account address

*-- After issuing
*-- 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?
Subquestion is: Does it work same (wrong) way for you in VFP?

Similar code executed from VB.NET works correctly... (see e.g.

Thanks for all responses

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 17 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 17 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros