View Single Post
  #2  
Old March 11th 08, 03:31 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Sending appointment not using default profile

Under the Outlook object model, only one mail profile can be running at a time. If Outlook is already running, you can't perform a logon to another profile. For your scenario, you would need to use CDO 1.21 or, to avoid security prompts, Redemption (http://www.dimastr.com/redemption/) instead of Outlook objects.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"David" wrote in message ...
Hey all, I've search all the forum, tried many solution, but none of them
works for me

Here's my problem. I'm developping an application in VB6 that must send
appointment using Outlook ( we're using MicrosoftExchange ).

The problem is that i have two profiles bind to my outlook.
1-My regular profiles for my mail ( default ) called : MainProfile
2-The one that need to send all appointments called : AppointmentProfile

Whenever i try to send an appointment, it always use Mainprofile to send it,
even if i specified AppointmentProfile in the logon.

Note that the 'When starting Outlook use this profile' option in Outlook is
pointing at MainProfile in case it matters.

Thanks all for you help!!!

[CODE START HERE]
Dim olApp As outlook.Application
Dim olNs As outlook.NameSpace
Dim olCal As outlook.mapiFolder
Dim mapiSession As mapi.Session

Set olApp = CreateObject("Outlook.Application")
Set olNs = olApp.GetNamespace("MAPI")
Set olCal = olNs.GetDefaultFolder(olFolderCalendar)
Set mapiSession = New mapi.Session

mapiSession.Logon "AppointmentProfile", "", False

Dim olAppt As outlook.AppointmentItem
Set olAppt = olApp.CreateItem(olAppointmentItem)

(... fill the appointment ... )

olAppt.Send
olAppt.Save

mapiSession.Logoff

Set mapiSession = Nothing
[ END OF CODE]

Ads