Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Outlook automation - SendUsingAccount readonly in VFP...?

Avatar of pcelba
pcelbaFlag for Czechia asked on
FoxPro
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")
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 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
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?
Subquestion is: Does it work same (wrong) way for you in VFP?


Similar code executed from VB.NET works correctly... (see e.g. http://msdn.microsoft.com/en-us/library/bb207787.aspx)

Thanks for all responses
ASKER CERTIFIED SOLUTION
Avatar of mikegagnon
mikegagnon

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

Commented:
This problem has been solved!
Unlock 1 Answer and 17 Comments.
See Answers