|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Change appointment's label color with CDOEXPublic Sub CreateAppt() Dim appt As New CDO.Appointment Dim con As New ADODB.Connection con.Provider = "ExOLEDB.DataSource" Dim Pers As CDO.Person Dim Mbx As CDO.IMailbox Dim strUrl As String strUrl = "mailto:***@lab.assenede.com" Set Pers = New CDO.Person Pers.DataSource.Open strUrl Set Mbx = Pers.GetInterface("IMailbox") With appt .AllDayEvent = True .StartTime = #7/18/2005# .EndTime = #7/19/2005# .BusyStatus = "Free" .Subject = "Test CDO" .Location = "Assenede" .TextBody = "coco" con.Open Mbx.BaseFolder .DataSource.SaveToContainer Mbx.Calendar, con 'setting the fields value to an integer ..Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/82140003").Value = 3 'other field name i've found on the net ' ..Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8214").Value = 3 appt.Fields.Update appt.DataSource.Save End With With that named property you need to make sure you set value using a long otherwise the datatype gets set wrong on the property and Outlook wont display it correctly. The property that should work is ..Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8214").Value so something like this should work
set appt = createobject("CDO.Appointment") set con = createobject("ADODB.Connection") con.Provider = "ExOLEDB.DataSource" set Pers = createobject("CDO.Person") strUrl = "mailto:em***@yourdomain.com.au" Pers.DataSource.Open strUrl Set Mbx = Pers.GetInterface("IMailbox") With appt .AllDayEvent = True .StartTime = #7/18/2005# .EndTime = #7/19/2005# .BusyStatus = "Free" .Subject = "Test CDO" .Location = "Assenede" .TextBody = "coco" con.Open Mbx.BaseFolder ..Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/82140003").Value = clng(3) .fields.update .DataSource.SaveToContainer Mbx.Calendar, con end with Cheers Glen "jmbaeten" <j.m.bae***@ardeca.com> wrote in message news:42dcfc87$0$16473$ba620e4c@news.skynet.be... I've developped some CDO code for creating appointments in users mailboxes. Those appointments should be shown with a particular label color (first day = blue, last day = red). I found some code on the net to perform this, but it seems not to work. The appointment is created (all day event, subject and body are ok), but the color of the label remains white (in Outlook 2003). Has anybody an idea of what goes wrong in following code?Public Sub CreateAppt() Dim appt As New CDO.Appointment Dim con As New ADODB.Connection con.Provider = "ExOLEDB.DataSource" Dim Pers As CDO.Person Dim Mbx As CDO.IMailbox Dim strUrl As String strUrl = "mailto:***@lab.assenede.com" Set Pers = New CDO.Person Pers.DataSource.Open strUrl Set Mbx = Pers.GetInterface("IMailbox") With appt .AllDayEvent = True .StartTime = #7/18/2005# .EndTime = #7/19/2005# .BusyStatus = "Free" .Subject = "Test CDO" .Location = "Assenede" .TextBody = "coco" con.Open Mbx.BaseFolder .DataSource.SaveToContainer Mbx.Calendar, con 'setting the fields value to an integer ..Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/82140003").Value = 3 'other field name i've found on the net ' ..Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8214").Value = 3 appt.Fields.Update appt.DataSource.Save End With sorry that should have been
set appt = createobject("CDO.Appointment") set con = createobject("ADODB.Connection") con.Provider = "ExOLEDB.DataSource" set Pers = createobject("CDO.Person") strUrl = "mailto:em***@yourdomain.com.au" Pers.DataSource.Open strUrl Set Mbx = Pers.GetInterface("IMailbox") With appt .AllDayEvent = True .StartTime = #7/18/2005# .EndTime = #7/19/2005# .BusyStatus = "Free" .Subject = "Test CDO" .Location = "Assenede" .TextBody = "coco" con.Open Mbx.BaseFolder .Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8214").Value = clng(3) .fields.update .DataSource.SaveToContainer Mbx.Calendar, con end with "Glen Scales [MVP]" <gsca***@outlookexchange.com> wrote in message With that named property you need to make sure you set value using a long news:ORw4gMMjFHA.2444@TK2MSFTNGP10.phx.gbl... otherwise the datatype gets set wrong on the property and Outlook wont display it correctly. The property that should work is ..Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8214").Value so something like this should work set appt = createobject("CDO.Appointment") set con = createobject("ADODB.Connection") con.Provider = "ExOLEDB.DataSource" set Pers = createobject("CDO.Person") strUrl = "mailto:em***@yourdomain.com.au" Pers.DataSource.Open strUrl Set Mbx = Pers.GetInterface("IMailbox") With appt .AllDayEvent = True .StartTime = #7/18/2005# .EndTime = #7/19/2005# .BusyStatus = "Free" .Subject = "Test CDO" .Location = "Assenede" .TextBody = "coco" con.Open Mbx.BaseFolder .Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/82140003").Value = clng(3) .fields.update .DataSource.SaveToContainer Mbx.Calendar, con end with Cheers Glen "jmbaeten" <j.m.bae***@ardeca.com> wrote in message I've developped some CDO code for creating appointments in users mailboxes. news:42dcfc87$0$16473$ba620e4c@news.skynet.be... Those appointments should be shown with a particular label color (first day = blue, last day = red). I found some code on the net to perform this, but it seems not to work. The appointment is created (all day event, subject and body are ok), but the color of the label remains white (in Outlook 2003). Has anybody an idea of what goes wrong in following code? Public Sub CreateAppt() Dim appt As New CDO.Appointment Dim con As New ADODB.Connection con.Provider = "ExOLEDB.DataSource" Dim Pers As CDO.Person Dim Mbx As CDO.IMailbox Dim strUrl As String strUrl = "mailto:***@lab.assenede.com" Set Pers = New CDO.Person Pers.DataSource.Open strUrl Set Mbx = Pers.GetInterface("IMailbox") With appt .AllDayEvent = True .StartTime = #7/18/2005# .EndTime = #7/19/2005# .BusyStatus = "Free" .Subject = "Test CDO" .Location = "Assenede" .TextBody = "coco" con.Open Mbx.BaseFolder .DataSource.SaveToContainer Mbx.Calendar, con 'setting the fields value to an integer .Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/82140003").Value = 3 'other field name i've found on the net ' ..Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8214").Value = 3 appt.Fields.Update appt.DataSource.Save End With Thanx, works like a charm.
Show quote "Glen Scales [MVP]" <gsca***@outlookexchange.com> wrote in message ..Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-00000news:#x$YHPMjFHA.3336@tk2msftngp13.phx.gbl... > sorry that should have been > > set appt = createobject("CDO.Appointment") > set con = createobject("ADODB.Connection") > con.Provider = "ExOLEDB.DataSource" > set Pers = createobject("CDO.Person") > > > > strUrl = "mailto:em***@yourdomain.com.au" > Pers.DataSource.Open strUrl > Set Mbx = Pers.GetInterface("IMailbox") > > With appt > .AllDayEvent = True > .StartTime = #7/18/2005# > .EndTime = #7/19/2005# > .BusyStatus = "Free" > .Subject = "Test CDO" > .Location = "Assenede" > .TextBody = "coco" > con.Open Mbx.BaseFolder > 0000046}/0x8214").Value > = clng(3) ..Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-00000> .fields.update > .DataSource.SaveToContainer Mbx.Calendar, con > end with > > > "Glen Scales [MVP]" <gsca***@outlookexchange.com> wrote in message > news:ORw4gMMjFHA.2444@TK2MSFTNGP10.phx.gbl... > With that named property you need to make sure you set value using a long > otherwise the datatype gets set wrong on the property and Outlook wont > display it correctly. The property that should work is > 0000046}/0x8214").Value Show quote > so something like this should work ..Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-00000> > set appt = createobject("CDO.Appointment") > set con = createobject("ADODB.Connection") > con.Provider = "ExOLEDB.DataSource" > set Pers = createobject("CDO.Person") > > > > strUrl = "mailto:em***@yourdomain.com.au" > Pers.DataSource.Open strUrl > Set Mbx = Pers.GetInterface("IMailbox") > > With appt > .AllDayEvent = True > .StartTime = #7/18/2005# > .EndTime = #7/19/2005# > .BusyStatus = "Free" > .Subject = "Test CDO" > .Location = "Assenede" > .TextBody = "coco" > con.Open Mbx.BaseFolder > 0000046}/82140003").Value Show quote > = clng(3) ..Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-00000> .fields.update > .DataSource.SaveToContainer Mbx.Calendar, con > end with > > Cheers > Glen > > "jmbaeten" <j.m.bae***@ardeca.com> wrote in message > news:42dcfc87$0$16473$ba620e4c@news.skynet.be... > I've developped some CDO code for creating appointments in users mailboxes. > Those appointments should be shown with a particular label color (first day > = blue, last day = red). I found some code on the net to perform this, but > it seems not to work. The appointment is created (all day event, subject and > body are ok), but the color of the label remains white (in Outlook 2003). > Has anybody an idea of what goes wrong in following code? > > Public Sub CreateAppt() > > Dim appt As New CDO.Appointment > Dim con As New ADODB.Connection > con.Provider = "ExOLEDB.DataSource" > Dim Pers As CDO.Person > Dim Mbx As CDO.IMailbox > > Dim strUrl As String > strUrl = "mailto:***@lab.assenede.com" > Set Pers = New CDO.Person > Pers.DataSource.Open strUrl > Set Mbx = Pers.GetInterface("IMailbox") > > With appt > .AllDayEvent = True > .StartTime = #7/18/2005# > .EndTime = #7/19/2005# > .BusyStatus = "Free" > .Subject = "Test CDO" > .Location = "Assenede" > .TextBody = "coco" > con.Open Mbx.BaseFolder > .DataSource.SaveToContainer Mbx.Calendar, con > 'setting the fields value to an integer > 0000046}/82140003").Value > = 3 ..Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-00000> 'other field name i've found on the net > ' > 0000046}/0x8214").Value Show quote > = 3 > appt.Fields.Update > appt.DataSource.Save > End With > > i have put the code that you suggest to me : the appointment is put correctly
in outlook like my code but the color is white. CDO.Appointment iAppt = new CDO.Appointment(); ADODB.Connection Conn = new ADODB.Connection(); Conn.Provider = "ExOLEDB.DataSource"; iAppt.StartTime = StartTime; iAppt.EndTime = EndTime; iAppt.Subject = Subject; iAppt.Location = Location; iAppt.TextBody = TextBody; iAppt.BusyStatus = BusyStatus; iAppt.Fields["http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/82140003"].Value = long.Parse("5"); iAppt.Fields.Update(); Conn.Open(iMbx.BaseFolder, "", "", -1); iAppt.DataSource.SaveToContainer(iMbx.Calendar, null, ADODB.ConnectModeEnum.adModeReadWrite, ADODB.RecordCreateOptionsEnum.adCreateNonCollection, ADODB.RecordOpenOptionsEnum.adOpenSource, "", ""); Conn.Close(); please help me ! Show quote "Glen Scales [MVP]" wrote: > sorry that should have been > > set appt = createobject("CDO.Appointment") > set con = createobject("ADODB.Connection") > con.Provider = "ExOLEDB.DataSource" > set Pers = createobject("CDO.Person") > > > > strUrl = "mailto:em***@yourdomain.com.au" > Pers.DataSource.Open strUrl > Set Mbx = Pers.GetInterface("IMailbox") > > With appt > .AllDayEvent = True > .StartTime = #7/18/2005# > .EndTime = #7/19/2005# > .BusyStatus = "Free" > .Subject = "Test CDO" > .Location = "Assenede" > .TextBody = "coco" > con.Open Mbx.BaseFolder > .Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8214").Value > = clng(3) > .fields.update > .DataSource.SaveToContainer Mbx.Calendar, con > end with > > > "Glen Scales [MVP]" <gsca***@outlookexchange.com> wrote in message > news:ORw4gMMjFHA.2444@TK2MSFTNGP10.phx.gbl... > With that named property you need to make sure you set value using a long > otherwise the datatype gets set wrong on the property and Outlook wont > display it correctly. The property that should work is > ..Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8214").Value > so something like this should work > > set appt = createobject("CDO.Appointment") > set con = createobject("ADODB.Connection") > con.Provider = "ExOLEDB.DataSource" > set Pers = createobject("CDO.Person") > > > > strUrl = "mailto:em***@yourdomain.com.au" > Pers.DataSource.Open strUrl > Set Mbx = Pers.GetInterface("IMailbox") > > With appt > .AllDayEvent = True > .StartTime = #7/18/2005# > .EndTime = #7/19/2005# > .BusyStatus = "Free" > .Subject = "Test CDO" > .Location = "Assenede" > .TextBody = "coco" > con.Open Mbx.BaseFolder > .Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/82140003").Value > = clng(3) > .fields.update > .DataSource.SaveToContainer Mbx.Calendar, con > end with > > Cheers > Glen > > "jmbaeten" <j.m.bae***@ardeca.com> wrote in message > news:42dcfc87$0$16473$ba620e4c@news.skynet.be... > I've developped some CDO code for creating appointments in users mailboxes. > Those appointments should be shown with a particular label color (first day > = blue, last day = red). I found some code on the net to perform this, but > it seems not to work. The appointment is created (all day event, subject and > body are ok), but the color of the label remains white (in Outlook 2003). > Has anybody an idea of what goes wrong in following code? > > Public Sub CreateAppt() > > Dim appt As New CDO.Appointment > Dim con As New ADODB.Connection > con.Provider = "ExOLEDB.DataSource" > Dim Pers As CDO.Person > Dim Mbx As CDO.IMailbox > > Dim strUrl As String > strUrl = "mailto:***@lab.assenede.com" > Set Pers = New CDO.Person > Pers.DataSource.Open strUrl > Set Mbx = Pers.GetInterface("IMailbox") > > With appt > .AllDayEvent = True > .StartTime = #7/18/2005# > .EndTime = #7/19/2005# > .BusyStatus = "Free" > .Subject = "Test CDO" > .Location = "Assenede" > .TextBody = "coco" > con.Open Mbx.BaseFolder > .DataSource.SaveToContainer Mbx.Calendar, con > 'setting the fields value to an integer > .Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/82140003").Value > = 3 > 'other field name i've found on the net > ' > ..Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8214").Value > = 3 > appt.Fields.Update > appt.DataSource.Save > End With > > > A couple of things make sure you use
http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8214 as the property (I made a mistake in the first post and posted a correction which you may not have seen) . Also Long types are a bit different between VB and C# in VB a long type is a 32 bit Integer where in C# its 64 Bits so when you try and use long in C# it sets that datatype get set to PT_I8 which Outlook doesn't expect for this property. The easy fix is just to use int32 in C# eg. CDO.Person iPerson; CDO.IMailbox iMailbox; string strEmailAddress = "MAILTO:u***@address.com"; iPerson = new CDO.PersonClass(); iPerson.DataSource.Open(strEmailAddress,null, ADODB.ConnectModeEnum.adModeRead,ADODB.RecordCreateOptionsEnum.adFailIfNotExists,ADODB.RecordOpenOptionsEnum.adOpenSource,String.Empty,String.Empty); iMailbox =(CDO.IMailbox)iPerson.GetInterface("IMailbox"); CDO.Appointment iAppt = new CDO.Appointment(); ADODB.Connection Conn = new ADODB.Connection(); Conn.Provider = "ExOLEDB.DataSource"; iAppt.StartTime = System.DateTime.Now; iAppt.EndTime = System.DateTime.Now.AddHours(2); iAppt.Subject = "Blah"; iAppt.Location = "Somewhere"; iAppt.TextBody = "Blah"; iAppt.BusyStatus = "Free"; iAppt.Fields["http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8214"].Value = Int32.Parse("3"); iAppt.Fields.Update(); Conn.Open(iMailbox.BaseFolder, "", "", -1); iAppt.DataSource.SaveToContainer(iMailbox.Calendar, null, ADODB.ConnectModeEnum.adModeReadWrite, ADODB.RecordCreateOptionsEnum.adCreateNonCollection, ADODB.RecordOpenOptionsEnum.adOpenSource, "", ""); Conn.Close(); Cheers Glen Show quote "genius33" <geniu***@discussions.microsoft.com> wrote in message news:56E38D94-895A-470B-9FEB-1E15EADE5408@microsoft.com... >i have put the code that you suggest to me : the appointment is put >correctly > in outlook like my code but the color is white. > CDO.Appointment iAppt = new CDO.Appointment(); > ADODB.Connection Conn = new ADODB.Connection(); > Conn.Provider = "ExOLEDB.DataSource"; > > iAppt.StartTime = StartTime; > iAppt.EndTime = EndTime; > iAppt.Subject = Subject; > iAppt.Location = Location; > iAppt.TextBody = TextBody; > iAppt.BusyStatus = BusyStatus; > iAppt.Fields["http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/82140003"].Value > = long.Parse("5"); > iAppt.Fields.Update(); > > Conn.Open(iMbx.BaseFolder, "", "", -1); > iAppt.DataSource.SaveToContainer(iMbx.Calendar, null, > ADODB.ConnectModeEnum.adModeReadWrite, > ADODB.RecordCreateOptionsEnum.adCreateNonCollection, > ADODB.RecordOpenOptionsEnum.adOpenSource, "", ""); > Conn.Close(); > please help me ! > > "Glen Scales [MVP]" wrote: > >> sorry that should have been >> >> set appt = createobject("CDO.Appointment") >> set con = createobject("ADODB.Connection") >> con.Provider = "ExOLEDB.DataSource" >> set Pers = createobject("CDO.Person") >> >> >> >> strUrl = "mailto:em***@yourdomain.com.au" >> Pers.DataSource.Open strUrl >> Set Mbx = Pers.GetInterface("IMailbox") >> >> With appt >> .AllDayEvent = True >> .StartTime = #7/18/2005# >> .EndTime = #7/19/2005# >> .BusyStatus = "Free" >> .Subject = "Test CDO" >> .Location = "Assenede" >> .TextBody = "coco" >> con.Open Mbx.BaseFolder >> >> .Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8214").Value >> = clng(3) >> .fields.update >> .DataSource.SaveToContainer Mbx.Calendar, con >> end with >> >> >> "Glen Scales [MVP]" <gsca***@outlookexchange.com> wrote in message >> news:ORw4gMMjFHA.2444@TK2MSFTNGP10.phx.gbl... >> With that named property you need to make sure you set value using a long >> otherwise the datatype gets set wrong on the property and Outlook wont >> display it correctly. The property that should work is >> ..Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8214").Value >> so something like this should work >> >> set appt = createobject("CDO.Appointment") >> set con = createobject("ADODB.Connection") >> con.Provider = "ExOLEDB.DataSource" >> set Pers = createobject("CDO.Person") >> >> >> >> strUrl = "mailto:em***@yourdomain.com.au" >> Pers.DataSource.Open strUrl >> Set Mbx = Pers.GetInterface("IMailbox") >> >> With appt >> .AllDayEvent = True >> .StartTime = #7/18/2005# >> .EndTime = #7/19/2005# >> .BusyStatus = "Free" >> .Subject = "Test CDO" >> .Location = "Assenede" >> .TextBody = "coco" >> con.Open Mbx.BaseFolder >> >> .Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/82140003").Value >> = clng(3) >> .fields.update >> .DataSource.SaveToContainer Mbx.Calendar, con >> end with >> >> Cheers >> Glen >> >> "jmbaeten" <j.m.bae***@ardeca.com> wrote in message >> news:42dcfc87$0$16473$ba620e4c@news.skynet.be... >> I've developped some CDO code for creating appointments in users >> mailboxes. >> Those appointments should be shown with a particular label color (first >> day >> = blue, last day = red). I found some code on the net to perform this, >> but >> it seems not to work. The appointment is created (all day event, subject >> and >> body are ok), but the color of the label remains white (in Outlook 2003). >> Has anybody an idea of what goes wrong in following code? >> >> Public Sub CreateAppt() >> >> Dim appt As New CDO.Appointment >> Dim con As New ADODB.Connection >> con.Provider = "ExOLEDB.DataSource" >> Dim Pers As CDO.Person >> Dim Mbx As CDO.IMailbox >> >> Dim strUrl As String >> strUrl = "mailto:***@lab.assenede.com" >> Set Pers = New CDO.Person >> Pers.DataSource.Open strUrl >> Set Mbx = Pers.GetInterface("IMailbox") >> >> With appt >> .AllDayEvent = True >> .StartTime = #7/18/2005# >> .EndTime = #7/19/2005# >> .BusyStatus = "Free" >> .Subject = "Test CDO" >> .Location = "Assenede" >> .TextBody = "coco" >> con.Open Mbx.BaseFolder >> .DataSource.SaveToContainer Mbx.Calendar, con >> 'setting the fields value to an integer >> >> .Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/82140003").Value >> = 3 >> 'other field name i've found on the net >> ' >> ..Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8214").Value >> = 3 >> appt.Fields.Update >> appt.DataSource.Save >> End With >> >> >> Thank you very much for all this information. That goes perfectly. I wish you
a good continuation. Show quote "Glen Scales [MVP]" wrote: > A couple of things make sure you use > http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8214 > as the property (I made a mistake in the first post and posted a correction > which you may not have seen) . Also Long types are a bit different between > VB and C# in VB a long type is a 32 bit Integer where in C# its 64 Bits so > when you try and use long in C# it sets that datatype get set to PT_I8 which > Outlook doesn't expect for this property. The easy fix is just to use int32 > in C# eg. > > > CDO.Person iPerson; > CDO.IMailbox iMailbox; > string strEmailAddress = "MAILTO:u***@address.com"; > iPerson = new CDO.PersonClass(); > iPerson.DataSource.Open(strEmailAddress,null, > ADODB.ConnectModeEnum.adModeRead,ADODB.RecordCreateOptionsEnum.adFailIfNotExists,ADODB.RecordOpenOptionsEnum.adOpenSource,String.Empty,String.Empty); > iMailbox =(CDO.IMailbox)iPerson.GetInterface("IMailbox"); > CDO.Appointment iAppt = new CDO.Appointment(); > ADODB.Connection Conn = new ADODB.Connection(); > Conn.Provider = "ExOLEDB.DataSource"; > iAppt.StartTime = System.DateTime.Now; > iAppt.EndTime = System.DateTime.Now.AddHours(2); > iAppt.Subject = "Blah"; > iAppt.Location = "Somewhere"; > iAppt.TextBody = "Blah"; > iAppt.BusyStatus = "Free"; > iAppt.Fields["http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8214"].Value > = Int32.Parse("3"); > iAppt.Fields.Update(); > Conn.Open(iMailbox.BaseFolder, "", "", -1); > iAppt.DataSource.SaveToContainer(iMailbox.Calendar, null, > ADODB.ConnectModeEnum.adModeReadWrite, > ADODB.RecordCreateOptionsEnum.adCreateNonCollection, > ADODB.RecordOpenOptionsEnum.adOpenSource, "", ""); > Conn.Close(); > > Cheers > Glen > > "genius33" <geniu***@discussions.microsoft.com> wrote in message > news:56E38D94-895A-470B-9FEB-1E15EADE5408@microsoft.com... > >i have put the code that you suggest to me : the appointment is put > >correctly > > in outlook like my code but the color is white. > > CDO.Appointment iAppt = new CDO.Appointment(); > > ADODB.Connection Conn = new ADODB.Connection(); > > Conn.Provider = "ExOLEDB.DataSource"; > > > > iAppt.StartTime = StartTime; > > iAppt.EndTime = EndTime; > > iAppt.Subject = Subject; > > iAppt.Location = Location; > > iAppt.TextBody = TextBody; > > iAppt.BusyStatus = BusyStatus; > > iAppt.Fields["http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/82140003"].Value > > = long.Parse("5"); > > iAppt.Fields.Update(); > > > > Conn.Open(iMbx.BaseFolder, "", "", -1); > > iAppt.DataSource.SaveToContainer(iMbx.Calendar, null, > > ADODB.ConnectModeEnum.adModeReadWrite, > > ADODB.RecordCreateOptionsEnum.adCreateNonCollection, > > ADODB.RecordOpenOptionsEnum.adOpenSource, "", ""); > > Conn.Close(); > > please help me ! > > > > "Glen Scales [MVP]" wrote: > > > >> sorry that should have been > >> > >> set appt = createobject("CDO.Appointment") > >> set con = createobject("ADODB.Connection") > >> con.Provider = "ExOLEDB.DataSource" > >> set Pers = createobject("CDO.Person") > >> > >> > >> > >> strUrl = "mailto:em***@yourdomain.com.au" > >> Pers.DataSource.Open strUrl > >> Set Mbx = Pers.GetInterface("IMailbox") > >> > >> With appt > >> .AllDayEvent = True > >> .StartTime = #7/18/2005# > >> .EndTime = #7/19/2005# > >> .BusyStatus = "Free" > >> .Subject = "Test CDO" > >> .Location = "Assenede" > >> .TextBody = "coco" > >> con.Open Mbx.BaseFolder > >> > >> .Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8214").Value > >> = clng(3) > >> .fields.update > >> .DataSource.SaveToContainer Mbx.Calendar, con > >> end with > >> > >> > >> "Glen Scales [MVP]" <gsca***@outlookexchange.com> wrote in message > >> news:ORw4gMMjFHA.2444@TK2MSFTNGP10.phx.gbl... > >> With that named property you need to make sure you set value using a long > >> otherwise the datatype gets set wrong on the property and Outlook wont > >> display it correctly. The property that should work is > >> ..Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8214").Value > >> so something like this should work > >> > >> set appt = createobject("CDO.Appointment") > >> set con = createobject("ADODB.Connection") > >> con.Provider = "ExOLEDB.DataSource" > >> set Pers = createobject("CDO.Person") > >> > >> > >> > >> strUrl = "mailto:em***@yourdomain.com.au" > >> Pers.DataSource.Open strUrl > >> Set Mbx = Pers.GetInterface("IMailbox") > >> > >> With appt > >> .AllDayEvent = True > >> .StartTime = #7/18/2005# > >> .EndTime = #7/19/2005# > >> .BusyStatus = "Free" > >> .Subject = "Test CDO" > >> .Location = "Assenede" > >> .TextBody = "coco" > >> con.Open Mbx.BaseFolder > >> > >> .Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/82140003").Value > >> = clng(3) > >> .fields.update > >> .DataSource.SaveToContainer Mbx.Calendar, con > >> end with > >> > >> Cheers > >> Glen > >> > >> "jmbaeten" <j.m.bae***@ardeca.com> wrote in message > >> news:42dcfc87$0$16473$ba620e4c@news.skynet.be... > >> I've developped some CDO code for creating appointments in users > >> mailboxes. > >> Those appointments should be shown with a particular label color (first > >> day > >> = blue, last day = red). I found some code on the net to perform this, > >> but > >> it seems not to work. The appointment is created (all day event, subject > >> and > >> body are ok), but the color of the label remains white (in Outlook 2003). > >> Has anybody an idea of what goes wrong in following code? > >> > >> Public Sub CreateAppt() > >> > >> Dim appt As New CDO.Appointment > >> Dim con As New ADODB.Connection > >> con.Provider = "ExOLEDB.DataSource" > >> Dim Pers As CDO.Person > >> Dim Mbx As CDO.IMailbox > >> > >> Dim strUrl As String > >> strUrl = "mailto:***@lab.assenede.com" > >> Set Pers = New CDO.Person > >> Pers.DataSource.Open strUrl > >> Set Mbx = Pers.GetInterface("IMailbox") > >> > >> With appt > >> .AllDayEvent = True > >> .StartTime = #7/18/2005# > >> .EndTime = #7/19/2005# > >> .BusyStatus = "Free" > >> .Subject = "Test CDO" > >> .Location = "Assenede" > >> .TextBody = "coco" > >> con.Open Mbx.BaseFolder > >> .DataSource.SaveToContainer Mbx.Calendar, con > >> 'setting the fields value to an integer > >> > >> .Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/82140003").Value > >> = 3 > >> 'other field name i've found on the net > >> ' > >> ..Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8214").Value > >> = 3 > >> appt.Fields.Update > >> appt.DataSource.Save > >> End With > >> > >> > >> > > > |
|||||||||||||||||||||||