Results 1 to 5 of 5

Thread: Entering an appiontment into Outlook...heellpp!!!

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Posts
    9

    Talking


    I'm trying to enter an appiontment into Outlook, for the default user, with the following code -

    Public Sub gnlAddBirthday(ByVal strKidsName, ByVal dteBirthday)
    Dim olAppt As outlook.AppointmentItem
    Dim strDate As String
    Dim strYear As String
    Dim strBDate As String
    Dim strBRest As String
    Dim strBirthday As String
    Dim winHwnd As Long
    Dim boolOpened As Boolean

    boolOpened = False

    Screen.MousePointer = vbHourglass

    Set olApp = New outlook.Application
    Set olNameSpace = olApp.GetNamespace("MAPI")
    olNameSpace.Logoff
    olNameSpace.Logon

    Set olRecipient = olNameSpace.CreateRecipient(olNameSpace.CurrentUser.Name)
    Set olAppt = olNameSpace.GetSharedDefaultFolder(olRecipient, olFolderCalendar).Items.Add

    With olAppt
    .Subject = strKidsName + "'s Birthday"
    .Body = "It's " + strKidsName + "'s Birthday today"

    strDate = CDate(Date)
    strYear = Right(strDate, 2)

    strBDate = CDate(dteBirthday)
    strBRest = Left(strBDate, 6)

    strBirthday = strBRest + strYear

    .Start = CDate(strBirthday + " 08:00 AM")
    .End = CDate(strBirthday + " 08:01 AM")
    .ReminderMinutesBeforeStart = "15"
    .ReminderPlaySound = True
    .Save
    End With

    Set olAppt = Nothing
    Screen.MousePointer = vbDefault

    End Sub

    Can somebody please tell me what is wrong with this!!

  2. #2
    Addicted Member
    Join Date
    Jan 2000
    Location
    Fresno, California, USA
    Posts
    195
    What is it doing (or not doing) that is bad or unexpected? This will help us know where in your code to look.

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Posts
    9

    When it hits Set olAppt I get the following -

    Run-time error - 1733165047(98b20009)
    Outlook does not recognise one or more names!


  4. #4
    Addicted Member
    Join Date
    Jan 2000
    Location
    Fresno, California, USA
    Posts
    195
    I copied your code into a new form, added the objects it needed to execute, and added a birthday reminder. It worked both with and without Outlook running. The error message indicates that your createrecipient statement didn't work. Check your error code at that point. Does the machine that is running this have Outlook installed and a default user assigned? If not, Outlook needs to be installed, and either your logon needs to have a user and password, or you need a default Outlook user.

  5. #5

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Posts
    9

    I have Outlook installed, and there is only one account, which automatically is the default. Is there any way to get round the Username, Password entry??


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width