473,406 Members | 2,259 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Create an Outlook Appointment and set the Label - with CDO in C# - Problems

Hi,
i found this code from outlookcode.com
http://www.outlookcode.com/codedetail.aspx?id=139

Its written in VB, and i have some problem porting it to C#.

The problem is getting the right appointment. An Exception occurs in
this line:
MAPI.Field oField = (MAPI.Field) oFields.get_Item(CdoAppt_Colors,
CdoPropSetID1);

My Code so far:
Microsoft.Office.Interop.Outlook.AppointmentItem appItem =
(Microsoft.Office.Interop.Outlook.AppointmentItem) outlookApp.CreateItem(OlItemType.olAppointmentItem );
appItem.Body = "Test!";

DateTime now = DateTime.Now; // start and end time
appItem.Start = now.AddHours(1);
appItem.End = now.AddHours(2);
appItem.Subject= "This is a test";
appItem.Save();
Object vEmpty = Missing.Value;
MAPI.Session oSession = new MAPI.Session();
oSession.Logon(vEmpty, vEmpty, true, true, 0, true, vEmpty);
const string CdoPropSetID1 = "0220060000000000C000000000000046"; //
const string CdoAppt_Colors = "0x8214"; // label property

MAPI.Folder oFolder =
(MAPI.Folder)oSession.GetDefaultFolder(MAPI.CdoDef aultFolderTypes.CdoDefaultFolderCalendar);

MessageBox.Show("Folder: "+ oFolder.Name);
if(appItem.EntryID!="")
{
MAPI.Fields oFields = (MAPI.Fields)oFolder.Fields;
MAPI.Field oField = (MAPI.Field) oFields.get_Item(CdoAppt_Colors,
CdoPropSetID1);

if(oField == vEmpty)
{
oFields.Add(CdoAppt_Colors, vEmpty, 2, CdoPropSetID1); // 2 is for
the second label
}
else
{
oField.Value = 2; // 2 is for the second label
}
}

Mar 2 '06 #1
0 1976

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jeff Mikels | last post by:
Here is a python script to synchronize Palm Desktop Datebook files with Outlook's Calendar I'm releasing it under the Python license as version 0.1. ...
0
by: Akira | last post by:
Could someone tell me how to send outlook appointment email from asp page? I would like appointment email just like one outlook can send out. I tried to look for an answer for this, but it seems...
3
by: Sam | last post by:
My db looks after the hiring and lending of equipment, the form which books out equipment hired prints a signout sheet and automatically inserts an appointment into outlook advising the operator on...
2
by: Kamyk | last post by:
Hello all! I have created a function in VB which generate appointment in Outlook. Everything is OK, except one thing. I cannot send it automatically using a button in Access, because I don`t...
1
by: mal_lori | last post by:
Hello, I have basic code to Creat an Outlook appointment and add Access Data. (code below) This works to add appointments to the basic calendar in my user folder. However I wish to add it to a...
0
by: saurabhaggarwal | last post by:
Hi Suppose there is backend that stores all the appointments that are currently there in outlook. The job of my plugin is to add all the appointments that are there in outlook back to the...
1
by: jodyblau | last post by:
I am using the code provided by MSDN to set an appointment on my Outlook. However, I would like to adjust this code so that instead of setting the appointment on in Outlook on my computer, it...
1
by: GraemeC | last post by:
I have a database that is used to book venues and assign people to those venues. The person doing the booking can send an appointment request from Access to an individuals Outlook calendar. This part...
0
by: swdesh | last post by:
Hi I am creating one outlook add-in using VSTO 2005 SE. I need to track all appointment event. I have used the following code.. Private Sub initializeEvent() Dim olFolder As...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.