Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OBJECT OUTLOOK APPLICATION 1

Status
Not open for further replies.

VisualQie

Programmer
Jul 22, 2010
6
FR
Hi everybody
I want to change the default Outlook account before sending a mail.
Actually, my code (VFP9 SP2) is something like this :

oOutlook=Createobject("outlook.application")
oItem=oOutlook.createitem(0)
oItem.subject ="TEST"
oItem.To="tonton@wanadoudou.fr"
oItem.Importance=2
.......something with "SendUsingAccount" but I can't use it.
oItem.display()
oOutlook=.Null.

Does somebody is able to help me by giving the correct syntax for a good solution ?

Thanks a lot.
Bests regards.
JpG
 

Create your self different profiles (Control panel-mail) and switch between them.
Code:
#Define MAILITEM 0
 #Define IMPORTANCENORMAL 1

 oOutlookObject=Createobject('outlook.application')
 oNameSpace=oOutlookObject.getNameSpace('mapi')
 oNameSpace.Logon('outlook2')
 oEmailItem = oOutlookObject.CreateItem(MAILITEM)
With oEmailItem
   .Recipients.Add('me@somewhere.com') && uses the Recipients collection
   .Subject = 'Automation sample'
   .Importance = IMPORTANCENORMAL
   .Body = 'This is easy!'
   .Send
Endwith
 oNameSpace.Logoff
Release oEmailItem
Release oOutlookObject

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Hi Mike.
Thanks for your quick answer.
That is exactly what I need. So a star for you.
This parameter 'outlook2' for LOGON() was unknown for me ...

Best regard.
JPG
 
'outlook2' is the name of the other outlook profile, it's not always 'outlook2'. This has to be individually changed.
What's new to you is to use the Logon to the mapi namespace. And it has to be done, before you even create the mail item.

Bye, Olaf.
 
Hi Olaf,
Yes. The first profile was 'exchange' and we have create a new profile 'outlook', and then use logon on mapi namespace as Mike said.
Now the mails are sent without any problem from the desired profile.
Thank you very much for this clarification.
Best regards.
JpG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top