Error when logging into exchange account only in vb6 program, but not in outlook 2003

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • twhitehouse
    New Member
    • Jul 2007
    • 2

    Error when logging into exchange account only in vb6 program, but not in outlook 2003

    I have an error when trying to log into outlook accounts in my vb6 program. I do not have a problem logging into these same accounts using outlook 2003. I have googled and found most of the solutions refer to wsock32.dll is missing. I have a wsock32.dll file. And that also would not explain why I can log in to the accounts on our exchange server using outlook 2003.

    Anyways, here is my code: (it is still rough, but I just want to get past this and I will clean it up later for all you experts...lol) I may have pinpointed it to the IPM.Appointment error. I have checked my books and that looks correct though.

    Dim objSession As MAPI.Session
    Dim objFolder As MAPI.Folder
    Dim objMsgs As MAPI.Messages
    Dim objMsg As MAPI.Appointmen tItem
    Dim objField As MAPI.Fields

    Dim mar102007 As String
    Dim mar112007 As String
    Dim mar122007 As String
    Dim nov32007 As String
    Dim nov42007 As String
    Dim nov52007 As String

    Dim i As Long
    Dim numChecked As Long
    Dim temp As String
    Dim Count As Long
    Dim Subject As String
    Dim location As String

    Dim startDate As Date
    Dim endDate As Date

    Dim notes As String

    mar102007 = "03/10/2007"
    mar112007 = "03/11/2007"
    mar122007 = "03/12/2007"
    nov32007 = "11/03/2007"
    nov42007 = "11/04/2007"
    nov52007 = "11/05/2007"

    On Error GoTo ErrorHandler

    If Check4.Value <> 1 And Check5.Value <> 1 And Check6.Value <> 1 And Check7.Value <> 1 Then
    MsgBox "You must check one of the check boxes of a year to the left to run this program"
    Exit Sub

    End If

    Set objSession = New MAPI.Session

    objSession.Logo n 'must logon before you can use objSession
    Set objFolder = objSession.GetD efaultFolder(Cd oDefaultFolderC alendar)
    Set objMsgs = objFolder.Messa ges

    If Check4.Value = 1 Then
    Count = Count + 1
    MsgBox "here"
    'it appears that this is need before you make the event to add to outlook
    objMsg.Type = "IPM.Appointmen t" 'this is erroring
    objMsg.Conversa tionIndex = objSession.Crea teConversationI ndex
    Set objMsg = objMsgs.Add

    'mar 10, 2007 10 pm to mar 11, 2007 6 am

    startDate = DateAdd("h", 22, mar102007)
    endDate = DateAdd("h", 6, mar112007)

    objMsg.Subject = "Regular event on March 10, 2007 from 10 pm to March 11, 2007 at 6 am"
    objMsg.Text = "Here is some text"
    objMsg.StartTim e = startDate
    objMsg.EndTime = endDate
    objMsg.location = "This is the location field"
    objMsg.Reminder Set = True
    'set reminder 15 minutes before startDate
    objMsg.Reminder MinutesBeforeSt art = 15

    Set objFields = objMsg.Fields
    objMsg.Update True, True

    DoEvents
    End If

    If Check5.Value = 1 Then
    Count = Count + 1
    End If

    If Check6.Value = 1 Then
    Count = Count + 1
    End If

    If Check7.Value = 1 Then
    Count = Count + 1
    End If

    Cleanup:
    MsgBox "enter exitsub"
    Set objFields = Nothing
    Set objMsg = Nothing
    Set objMsgs = Nothing
    Set objFolder = Nothing
    If Not objSession Is Nothing Then
    objSession.Logo ff
    Set objSession = Nothing
    End If
    MsgBox "exit exit sub"
    GoTo AtEnd

    ErrorHandler:
    MsgBox "Error Handler"
    MsgBox "Error Occurred: " & Err.Description & " [" & Err.Number & "]", vbOKOnly, "DSTMaker - Error"
    GoTo Cleanup

    AtEnd:
    MsgBox "Done"
    End Sub


    Thanks for the help in advance
  • fplesco
    New Member
    • Jul 2007
    • 82

    #2
    Hi twhitehouse -

    I am not familiar with this but I think, you miss your Account ID and Password. You must be sending that too as parameters.

    Comment

    Working...