Link to home
Create AccountLog in
Avatar of DCreature
DCreature

asked on

VB.Net application to add an appointment to Outlook 2003.

I have written a VB.Net application to add specified numbers of Days, Hours, and Minutes to current system date / time then display a result on a label as calculated date and time.

I want to have a new option which will allow a user to type some text into fields (subject / content of the appointment) then click a button "Add to Outlook" (Can this be any versions and not just 2003? If not then 2003 is fine) to add the currently displayed date and time to Outlook 2003 together with appointment's title and content text.
ASKER CERTIFIED SOLUTION
Avatar of DotNetLover_Baan
DotNetLover_Baan

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of DCreature
DCreature

ASKER

Thanks DotNetLover_Baan, however I would appreciate us all making Experts-Exchange a great place for source of knowledge and not just a web site that indexes bunches of links to other sites, which in the future, may or may not exist.

Thanks.
Having said that, here is the content found on some of those links:

(These information are from http://www.outlookcode.com).

Description: You can use the Namespace.GetSharedDefaultFolder method to access the Calendar folder in another Exchange mailbox. Keep in mind that you might not have permission to even see that folder, or you might have only read access.

Sub CreateOtherUserAppointment()
    Dim objApp As Outlook.Application
    Dim objNS As Outlook.NameSpace
    Dim objFolder As Outlook.MAPIFolder
    Dim objDummy As Outlook.MailItem
    Dim objRecip As Outlook.Recipient
    Dim objAppt As Outlook.AppointmentItem
    Dim strMsg As String
    Dim strName As String
    On Error Resume Next
   
    ' ### name of person whose Calendar you want to use ###
    strName = "FlaviusJ"
   
    Set objApp = CreateObject("Outlook.Application")
    Set objNS = objApp.GetNamespace("MAPI")
    Set objDummy = objApp.CreateItem(olMailItem)
    Set objRecip = objDummy.Recipients.Add(strName)
    objRecip.Resolve
    If objRecip.Resolved Then
        On Error Resume Next
        Set objFolder = _
          objNS.GetSharedDefaultFolder(objRecip, _
            olFolderCalendar)
        If Not objFolder Is Nothing Then
            Set objAppt = objFolder.Items.Add
            If Not objAppt Is Nothing Then
                With objAppt
                    .Subject = "Test Appointment"
                    .Start = Date + 14
                    .AllDayEvent = True
                    .Save
                End With
            End If
        End If
    Else
        MsgBox "Could not find " & Chr(34) & strName & Chr(34), , _
               "User not found"
    End If

    Set objApp = Nothing
    Set objNS = Nothing
    Set objFolder = Nothing
    Set objDummy = Nothing
    Set objRecip = Nothing
    Set objAppt = Nothing
End Sub

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

Content of another link:

Code level: intermediate    Code area: Outlook and .NET
Title: Outlook & mapi
Description: this C# code uses OOM and mapi to create an appointment in the current outlook profile

Outlook.Application oApp = new Outlook.ApplicationClass();
Outlook.NameSpace oNS = oApp.GetNamespace("mapi");
oNS.Logon("profileName", "Password", false, true);

Outlook.AppointmentItem oAppt = (Outlook.AppointmentItem)oApp.CreateItem(Outlook.OlItemType.olAppointmentItem);
oAppt.Subject = "Created using OOM in C#";
oAppt.Body = "Hello World";
oAppt.Location = "Samm E";
oAppt.Start = Convert.ToDateTime("03/08/2004 9:00:00 AM");
oAppt.End = Convert.ToDateTime("03/08/2004 1:00:00 PM");
oAppt.ReminderSet = true;
oAppt.ReminderMinutesBeforeStart = 5;
oAppt.BusyStatus = Outlook.OlBusyStatus.olBusy;
oAppt.IsOnlineMeeting = false;
                  
oAppt.Save();
oAppt.Display(true);

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