Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1263
  • Last Modified:

Updating Calendar using Outlook form.

I am trying to develop a Outlook Form in which user can fill the information about the meetings and send it to a specific email id in a Exchange 5.5 mail server. I also want to update the calendar of destination email-Id. For this on send event I am writing a code which is giving error: Collaboration Data Objects: [Collaboration Data Objects - [MAPI_E_LOGON_FAILED(80040111)]]

********************
Sub AddCal(strstart, strend, strSubject, strText)
    'on Error Resume Next
    Dim oSession ' As MAPI.Session
    Dim cdoFolder ' As MAPI.Folder
    Dim cdoMessages ' As MAPI.Messages
    Dim cdoAppointmentItem ' As MAPI.AppointmentItem
   
    strservername = "ismsrv13"
    profilename = "Ranjan, Mr. Manish"
   
    Set oSession = CreateObject("MAPI.Session")
   
    strProfile = strservername & vbLf & profilename
    oSession.Logon , , False, True, 0, True, strProfile
   
    Set cdoFolder = oSession.GetDefaultFolder(CdoDefaultFolderCalendar)
    Set cdoMessages = cdoFolder.Messages
    Set cdoAppointmentItem = cdoMessages.Add
    With cdoAppointmentItem
        .Subject = strSubject
        .Text = strText
        .StartTime = strstart
        .EndTime = strend
        .BusyStatus = CdoBusy
        .ReminderSet = False
    End With
   
    cdoAppointmentItem.Update
    oSession.Logoff
    Set cdoAppointmentItem = Nothing
    Set cdoMessages = Nothing
    Set cdoMessages = Nothing
msgbox("Calendar updaetd")
End Sub
********************
Early help will be highly appreciated
0
ManishRanjan
Asked:
ManishRanjan
  • 3
  • 2
1 Solution
 
fatthiefCommented:
when you are trying to logon a session by using the profileinfo(servename+mail alisa), make sure the computer that running the above application is logged with enough permission right to access that profile....
it's not clear? then you can try to use domain administrator to logon the computer and run the application, and you may find the difference
0
 
ManishRanjanAuthor Commented:
The Form I am developing will be used by more than 400 users. Anyone can use this form to book the Meeting room. On Send event, the form will write in the calendar of a specific profile, which is visible to all to check the free busy status.  
Now I am using different code to achieve this but it is writng in My calendar (Current User) itself.
*********************
Sub AddCal(strstart, strend, strSubject, strText)
      Set objSession = Application.CreateObject("MAPI.Session")
      'strRetCode = objSession.Logon(Application.GetNameSpace("MAPI").CurrentUser, "", False, False, 0)
      strRetCode = objSession.Logon("## Meeting Room", "", False, False, 0)

      ' Get UserName
      strUserName = objSession.CurrentUser

      ' If UserName not found
      If Trim(strUserName) = "" Then
            ' Error creating MAPI session, show error message and exit
            MsgBox "Undefinied error. Errorcode: Please contact your System Administrator", 48, "Microsoft Outlook"
            Item_Send = False
      Else            
            Set cdoFolder = objSession.GetDefaultFolder(CdoDefaultFolderCalendar)
            Set cdoMessages = cdoFolder.Messages
            Set cdoAppointmentItem = cdoMessages.Add
            With cdoAppointmentItem
              .Subject = strSubject
              .Text = strText
              .StartTime = strstart
              .EndTime = strend
              .BusyStatus = 2 'CdoBusy
              .ReminderSet = False
            End With    
            cdoAppointmentItem.Update

            objSession.Logoff
            Set cdoAppointmentItem = Nothing
            Set cdoMessages = Nothing
            Set cdoMessages = Nothing
      End If
End Sub

*********************

 I have quite limited knowledge about Outlook programming.
0
 
fatthiefCommented:
You can publish the form to a public folder(calendar) which anyone can access it
0
 
ManishRanjanAuthor Commented:
That is Okay, I am facing problem in Login in Destination Email ID (i.e. ('## Meeting Room')from the Outlook form.
0
 
fatthiefCommented:
If you want to login the Session by using the ProfileName & ProfilePassword parameters, no matters in what language, that ProfileName must be already existed on the machine that you run this form.  To check whether the profile is already installed or not, open "Mail" in the Control Panel from start menu.

However, it seems that you want to access someone's calendar whose profile has never created on your machine, then your should use ProfileInfo parameter instead of ProfileName. e.g.      
strRetCode = objSession.Logon("", ' ProfileName
"", ' ProfilePassword
True, ' ShowDialog
True, ' NewSession
0, ' ParentWindow
False, ' NoMail
"YourMailServer" & vblf & "ProfileName") ' ProfileInfo

Back to my previous comment, the computer that run this form should have the right to access the others' calendar in outlook.  

Actually I am also new to outlook programming.  I also face the similiar problem before and finally found these solutions.  The tricky point is the security management of the Exchange Server.  I am not sure is it the only way to solve it.  Hope they can help you and if you found some better solutions, please let me know :)
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now