?
Solved

write to outlook calender with visual basic / vbs

Posted on 2005-05-12
10
Medium Priority
?
281 Views
Last Modified: 2013-12-04
Hello Experts
Can somebody help me with and example of how to make an entry in the outlook calendar with visual basic.
0
Comment
Question by:aslandk
7 Comments
 
LVL 6

Expert Comment

by:TDSnet
ID: 13993422
Hi,

There are two types of Calendar entry in Outlook.  Appointments and Meetings.  Here is an example of creating an Appointment:

1.  From the Project menu select References.  Tick the box next to the Microsoft Outlook Object Library entry.
2.  Place a Command Button on your Form named Command1.
3.  Double click the button in the forms designer which will take you to the code window in the button's Click Event Handler.
4.  Make your code look like this:

Private Sub Command1_Click()
Dim oAppl As New Outlook.Application
Dim oAppt As Outlook.AppointmentItem
  Set oAppt = oAppl.CreateItem(oAppointmentItem)
  With oAppt
    .Body = "Body"
    .Subject = "Subject"
    .Location = "Location"
    .Duration = 30
    .ReminderMinutesBeforeStart = 10
    .ReminderPlaySound = True
    .Start = CDate("15-05-2005 12:00:00")
    .Save
  End With
End Sub

Run your program and click the command button.  Check your Outlook Calendar for the 15th of May 2005 and your new Appointment entry will be there.

Cheers,
Jack
0
 
LVL 33

Expert Comment

by:CarlWarner
ID: 13993426
OL97: Use OLE Automation with Microsoft Outlook 97
http://support.microsoft.com/default.aspx?scid=kb;en-us;170262

Adding a New Appointment section
0
 

Author Comment

by:aslandk
ID: 13993517
Hello TDSnet

The error "type mismatch in line":

 Set oAppt = oAppl.CreateItem(oAppointmentItem)

Dont now what is wrong do you?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Accepted Solution

by:
TDSnet earned 2000 total points
ID: 13993531
Sorry mate...My bad.  I really should test this stuff before I post it :-)

Change that line to:

Set oAppt = oAppl.CreateItem(olAppointmentItem)

I forgot the "l" in olAppointmentItem

Cheers,
Jack
0
 

Author Comment

by:aslandk
ID: 13993971
Yes i works.....

THX Jack

Do you now where to find some examples about adding entry's to other things in outlook(inbox, notes...etc)?
0
 
LVL 6

Expert Comment

by:TDSnet
ID: 13994183
It all works based on the same basic idea.  If you just have a play around with it you will see what I mean:

1.  Declare your Outlook.Application object
2.  Use that to create the item you want to add (MailItem, MeetingItem, ContactItem, AppointmentItem, etc)
     ie.  Outlook.Application.CreateItem(olMailItem)
3.  Set relevant Properties for that particular item type
     ie.  With myMailItem
             .Subject = "Hi"
             .HtmlBody = "Something"
             .Send
           End With

If you just play around with that concept then you will find you can create whatever you want.

Cheers,
Jack
0
 

Expert Comment

by:ashugarg00
ID: 14186049
Hello
I am preparing an addin in VB for MS outlook.

I have written the following code which helps me to add an appointment item to any date of the calendar.
' Dim myCalendar As Outlook.MAPIFolder
 Set myCalendar = oNS.GetDefaultFolder(olFolderCalendar)
 Set colCalItems = myCalendar.Items

Set objAppointment = oApp.CreateItem(olAppointmentItem)
       
    With objAppointment
        .Body = "Some text"
        .BusyStatus = olBusy
        .Start = #6/10/2005 6:00:00 AM#
        .Duration = 60
        .Subject = "My Appointment"
        .Save
    End With  
       
Now I need to program for two things
1.  I need to capture the click on the calendar in outlook. ie when the user clicks any particular date of any month or year on the calendar the information should be stored in the calendar object. I must be able to open my add in on clicking any date. Can this be done?
2.  How do i get the selected date for any particular month or year to be stored in my calendar object. ie If the user clicks 1st May 2005 then my addin should open and i should be able to get 1 st May 2005 to be stored in my calendar object.

Waiting for ur answer.
Thanks and regards,
Sainath.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
Introduction to Processes
Screencast - Getting to Know the Pipeline

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question