Le forum (ô combien francophone) des utilisateurs de Powerbuilder.
Bonjour.
Comment faire pour créer (ça, j'ai plus au moins trouvé) et surtout modifier un événement Outlook précis depuis une application en PB 10.2.0 Build 8035 ?
Essai de création d'un champ utilisateur dans Outlook avec une valeur affectée par PB, mais je n'ai pas la méthode qui permet de retrouver celui-ci pour une modification.
Utilisateur d'Outlook 2003
Merci d'avance
Hors ligne
bonjour,
c'est possible que tu nous partages tes bouts de codes ? afin qu'on puisse voir ensemble pour la suite ?
A+ (et welcome)
Hors ligne
Voici le code repris depuis un site et aménagé :
// I want to pass meetings info from pb application to ms outlook calendar. // It works for creation, but i also want to update if modified in pb applic. // Therefore i need to store mykey somewhere in this calendar record. // I have add a field in outlook in which i intend to store mykey. // The creation of the userfield works well (i can see it with // outlookspy) but when i want to store an info in it, nothing // happens. (no info, but no errors mentionned) // // // If i update this outlook userfield it through outlookspy, it // works: i can store and later on retrieve through pb this // Keyid // // // I checked on different newsgroup, and did not find the error // In my syntax. // // // This is the piece of code used as prototype: // tests à déplacer dans wf_valider If dw_action.Object.com_id[1] <> gl_Comid & And dw_en_copie.Find ('com_id = ' + String (gl_Comid), 0, dw_en_copie.RowCount ()) = 0 Then Msg.Box ('Outlook', "Vous n'êtes pas un commercial lié à l'action.~r~nVous ne pouvez pas enregistrer celle-ci dans votre calendrier", StopSign!) Return ElseIf ib_modif Then Msg.Box ('Outlook', "Veuillez valider vos modifications !", StopSign!) Return End If //OlDefaultFolders Constant Integer olFolderDeletedItems = 3 Constant Integer olFolderOutbox = 4 Constant Integer olFolderSentMail = 5 Constant Integer olFolderInbox = 6 Constant Integer olFolderCalendar = 9 Constant Integer olFolderContacts = 10 Constant Integer olFolderJournal = 11 Constant Integer olFolderNotes = 12 Constant Integer olFolderTasks = 13 // OL DEFAULT metting parameters Long olMailItem = 0, & olAppointmentItem = 1, & olContactItem = 2, & olTaskItem = 3, & olJuprnalItem = 4, & olMtItem = 5, & olPostItem = 6, & olNonMeeting = 0, & olMeeting = 1, & olMeetingReceived = 3, & olMeetingCanceled = 5, & ll_row Integer li_return String lsSubject, lsBody, lsLoc, lsType, lsMail Datetime ldtstart Time lt_date Integer lidur, liRemindBefore Long ll_count, Cx, ll_ComId Boolean alreadyDone DataWindowChild ldwc OLEObject ole_outlk, ole_space, ole_folder, ole_item, ole_task, ole_recip, ole_property ole_outlk = CREATE OLEObject li_return = ole_outlk.ConnectToNewObject ("outlook.application") ole_space = CREATE OLEObject ole_space = ole_outlk.GetNameSpace ("MAPI") // ************************************** // * SET Parms // ************************************** lsSubject = dw_action.Object.act_obj[1] ; If IsNull (lsSubject) Then lsSubject = '' lsBody = wf_mise_en_forme (dw_action.Object.cac_cmt[1]) ; If IsNull (lsBody) Then lsBody = '' lsLoc = dw_action.Object.act_lieu[1] ; If IsNull (lsLoc) Then lsLoc = '' lt_date = Time (dw_action.Object.date_time[1]) If IsNull (lt_date) Then lt_date = Time ('12:00') ldtStart = Datetime (Date (dw_action.Object.act_dat[1]), lt_date) dw_action.GetChild ('tac_id', ldwc) ll_row = ldwc.Find ('tac_id = ' + String (dw_action.Object.tac_id[1]), 0, ldwc.Rowcount ()) lsType = ldwc.GetItemString (ll_row, 'tac_lbl') If IsNull (dw_action.Object.dur_id[1]) Then liDur = 0 Else dw_action.GetChild ('dur_id', ldwc) ll_row = ldwc.Find ('dur_id = ' + String (dw_action.Object.dur_id[1]), 0, ldwc.Rowcount ()) Choose Case ldwc.GetItemString (ll_row, 'dur_type') Case 'SECONDES' liDur = Round (ldwc.GetItemNumber (ll_row, 'dur_longueur') / 60, 0) Case 'MINUTES' liDur = ldwc.GetItemNumber (ll_row, 'dur_longueur') Case 'HEURES' liDur = ldwc.GetItemNumber (ll_row, 'dur_longueur') * 60 Case 'JOURS' liDur = ldwc.GetItemNumber (ll_row, 'dur_longueur') * 1440 End Choose End If If dw_action.Object.act_ind_alarme[1] = 'O' Then liRemindBefore = Long (dw_action.Object.act_alarme[1]) ; If IsNull (liRemindBefore) Then liRemindBefore = 0 Else liRemindBefore = 0 End If // ************************************** // * CREATE a meeting // ************************************** ole_item = create OLEObject // création d'un événement Outlook -> il faut trouver le moyen de rechercher si l'événement n'existe pas déjà ole_item = ole_Outlk.CreateItem (olAppointmentItem) // création d'un nouvel événement Outlook // c'est cette partie de code que que je n'arrive pas à écrire correctement ole_item = ole_Outlk.Items.Find('[actid]=' + String (dw_action.object.act_id[1])) If IsNull (ole_item) Then ole_item = ole_Outlk.CreateItem (olAppointmentItem) // look If userproperty pmiX EXISTS, Create If Not ll_count = ole_item.UserProperties.Count alreadyDone = False For Cx = 1 To ll_count If ole_item.UserProperties (Cx).name = "actid" Then AlreadyDone = True Ole_Property = CREATE OLEObject ole_Property = ole_item.UserProperties (Cx) Exit End If Next // Direct storing does Not work ! //If Not alreadyDone Then ole_Property = ole_item.UserProperties.Add ("actid", 20) // type Integer = 20 //ole_Property.value = dw_action.object.act_id[1] // storing after creation, does Not work //Any a //a = ole_item.UserProperties ("MyField").value = "MyKey" ole_item.MeetingStatus = olMeeting ole_item.Subject = lsSubject ole_item.Location = lsLoc ole_item.Body = lsBody ole_item.Start = ldtStart ole_item.AllDayEvent = False If liDur > 0 then ole_item.Duration = liDur If liDur > 1440 Then ole_item.AllDayEvent = true End If If liRemindBefore > 0 Then ole_item.ReminderSet = True ole_item.ReminderMinutesBeforeStart = liRemindBefore Else ole_item.ReminderSet = False End If // recopie des commerciaux liés à l'action (à l'exception de l'utilisateur connecté) //If dw_action.Object.com_id[1] <> gl_comid Then // ll_comid = dw_action.Object.com_id[1] // select uti_e_mail INTO :lsMail FROM commercial c, utilisateur u where c.com_id = :ll_comid AND u.uti_id = c.uti_id; // ole_recip = ole_item.Recipients.Add (lsMail) // ole_recip.Type = 1 //?? quelles possibilités? // ole_recip.Resolve //End If // //For ll_row = dw_en_copie.RowCount () // If dw_en_copie.Object.com_id[ll_row] = gl_comid Then continue // ll_comid = dw_en_copie.Object.com_id[ll_row] // select uti_e_mail INTO :lsMail FROM commercial c, utilisateur u where c.com_id = :ll_comid AND u.uti_id = c.uti_id; // ole_recip = ole_item.Recipients.Add (lsMail) // ole_recip.Type = ole_outlk.OlMeetingRecipientType.olOptional //?? quelles possibilités? // ole_recip.Resolve //Next // // recopie de l'interlocuteur //lsMail = dw_action.Object.itl_e_mail[1] //ole_recip = ole_item.Recipients.Add (lsMail) //ole_recip.Type = ole_outlk.OlMeetingRecipientType.olRequired //ole_recip.Resolve ole_item.Save //ole_item.Send ole_item.Close (0) ole_outlk.DisConnectObject () Destroy ole_outlk Destroy ole_space Destroy ole_item Destroy ole_Property
Dernière modification par PhPairon (07-03-2008 09:53:01)
Hors ligne
à quel moment est crée l'event actid ?
genre... http://www.dotnet247.com/247reference/m … 78441.aspx
Hors ligne
Normalement, la propriété actid est un champ utilisateur créé dans Outlook préalablement
Un bout du code permet éventuellement de la créer si elle n'existe pas, mais tout n'est pas correctement mis en forme
ll_count = ole_item.UserProperties.Count alreadyDone = False For Cx = 1 To ll_count If ole_item.UserProperties (Cx).name = "actid" Then AlreadyDone = True Ole_Property = CREATE OLEObject ole_Property = ole_item.UserProperties (Cx) Exit End If Next // Direct storing does Not work ! If Not alreadyDone Then ole_Property = ole_item.UserProperties.Add ("actid", 20) // type Integer = 20
Dernière modification par PhPairon (07-03-2008 13:22:25)
Hors ligne
c'est bien ici, que ca ne fonctionne pas ?
ole_item = ole_Outlk.Items.Find('[actid]=' + String (dw_action.object.act_id[1]))
que vaut la valeur String (dw_action.object.act_id[1]) ?
si, essayes
ole_item = ole_Outlk.Items.Find("[actid]='" + String (dw_action.object.act_id[1])+"'")
sinon,
ole_item = ole_Outlk.Find("[actid]='" + String (dw_action.object.act_id[1])+"'")
Hors ligne
Oui, c'est bien là que ça coince, mais, non, le champ est déclaré comme type INT, donc pas de ' ou de "
Hors ligne
pour info... pour ton type int...
http://msdn2.microsoft.com/en-us/library/bb220350.aspx
Hors ligne
C'est plus ou moins décoincé.
Toutefois, j'ai encore un problème :
Je voudrais pouvoir ajouter des participants à l'événement Outlook.
Les scripts trouvés sur le Web ne fonctionnent pas
Voici mon script actuel :
// I want to pass meetings info from pb application to ms outlook calendar. // It works for creation, but i also want to update if modified in pb applic. // Therefore i need to store mykey somewhere in this calendar record. // I have add a field in outlook in which i intend to store mykey. // The creation of the userfield works well (i can see it with outlookspy) but when i want to store an info in it, nothing happens. (no info, but no errors mentionned) // // If i update this outlook userfield it through outlookspy, it works: i can store and later on retrieve through pb this Keyid // // I checked on different newsgroup, and did not find the error In my syntax. // // This is the piece of code used as prototype: SetPointer (HourGlass!) //OlDefaultFolders Constant Integer olFolderDeletedItems = 3 Constant Integer olFolderOutbox = 4 Constant Integer olFolderSentMail = 5 Constant Integer olFolderInbox = 6 Constant Integer olFolderCalendar = 9 Constant Integer olFolderContacts = 10 Constant Integer olFolderJournal = 11 Constant Integer olFolderNotes = 12 Constant Integer olFolderTasks = 13 // OL DEFAULT metting parameters Long olMailItem = 0, & olAppointmentItem = 1, & olContactItem = 2, & olTaskItem = 3, & olJuprnalItem = 4, & olMtItem = 5, & olPostItem = 6, & olNonMeeting = 0, & olMeeting = 1, & olMeetingReceived = 3, & olMeetingCanceled = 5, & ll_row Integer li_return String lsSubject, lsBody, lsLoc, lsType, lsMail Datetime ldtstart Time lt_date Integer lidur, liRemindBefore Long ll_count, Cx, ll_ComId Boolean alreadyDone DataWindowChild ldwc OLEObject ole_outlk, ole_space, ole_folder, ole_item, ole_task, ole_recip, ole_property ole_outlk = CREATE OLEObject li_return = ole_outlk.ConnectToNewObject ("outlook.application") ole_space = CREATE OLEObject ole_space = ole_outlk.GetNameSpace ("MAPI") // ************************************** // * SET Parms // ************************************** lsSubject = dw_action.Object.act_obj[1] ; If IsNull (lsSubject) Then lsSubject = '' lsLoc = dw_action.Object.act_lieu[1] ; If IsNull (lsLoc) Then lsLoc = '' // contenu du corps de l'événement lsBody = '' // société concernée lsBody += 'Société : ' + dw_action.Object.cli_soc[1] + ' ' + dw_action.Object.cli_soc[1] + '~r~n' lsBody += 'Adresse : ' If Not IsNull (dw_action.Object.cli_adr1_soc[1]) Then lsBody += dw_action.Object.cli_adr1_soc[1] + ' ' If Not IsNull (dw_action.Object.cli_adr2_soc[1]) Then lsBody += dw_action.Object.cli_adr2_soc[1] + ' ' If Not IsNull (dw_action.Object.cli_adr3_soc[1]) Then lsBody += dw_action.Object.cli_adr3_soc[1] + ' ' If Not IsNull (dw_action.Object.cli_codpost_soc[1]) And Not IsNull (dw_action.Object.cli_bdi_soc[1]) Then lsBody += dw_action.Object.cli_codpost_soc[1] + ' ' + dw_action.Object.cli_bdi_soc[1] + ' ' ElseIf Not IsNull (dw_action.Object.cli_codpost_soc[1]) Then lsBody += dw_action.Object.cli_codpost_soc[1] + ' ' ElseIf Not IsNull (dw_action.Object.cli_codpost_soc[1]) And Not IsNull (dw_action.Object.cli_bdi_soc[1]) Then lsBody += dw_action.Object.cli_bdi_soc[1] + ' ' End If If Not IsNull (dw_action.Object.pay_lbl[1]) Then lsBody += dw_action.Object.pay_lbl[1] + ' ' lsBody = Trim (lsBody) + '~r~n' If Not IsNull (dw_action.Object.cli_tel[1]) Then lsBody += 'Téléphone : ' + dw_action.Object.cli_tel[1] + '~r~n' If Not IsNull (dw_action.Object.cli_fax[1]) Then lsBody += 'Fax : ' + dw_action.Object.cli_fax[1] + '~r~n' lsBody += '~r~n' // contact lsBody += 'Contact : ' + dw_action.Object.civ_court[1] + ' ' + dw_action.Object.itl_nom[1] If IsNull (dw_action.Object.itl_prenom[1]) Then lsBody += '~r~n' Else lsBody += ' ' + dw_action.Object.itl_prenom[1] + '~r~n' If Not IsNull (dw_action.Object.telephone[1]) Then lsBody += 'Téléphone : ' + dw_action.Object.telephone[1] + '~r~n' If Not IsNull (dw_action.Object.fax[1]) Then lsBody += 'Fax : ' + dw_action.Object.fax[1] + '~r~n' If Not IsNull (dw_action.Object.itl_tel_mob[1]) Then lsBody += 'Mobile : ' + dw_action.Object.itl_tel_mob[1] + '~r~n' If Not IsNull (dw_action.Object.itl_e_mail[1]) Then lsBody += 'Courriel : ' + dw_action.Object.itl_e_mail[1] + '~r~n' If Not IsNull (dw_action.Object.fnc_lbl[1]) Then lsBody += 'Fonction : ' + dw_action.Object.fnc_lbl[1] + '~r~n' lsBody += '~r~n' // type d'action dw_action.GetChild ('tac_id', ldwc) ll_row = ldwc.Find ('tac_id = ' + String (dw_action.Object.tac_id[1]), 0, ldwc.Rowcount ()) lsType = ldwc.GetItemString (ll_row, 'tac_lbl') lsBody += 'Type : ' + lsType + '~r~n' lsBody += '~r~n' // commentaire If Not IsNull (dw_action.Object.cac_cmt[1]) Then lsBody += 'Objet : ' + wf_mise_en_forme (dw_action.Object.cac_cmt[1]) // date de début lt_date = Time (dw_action.Object.date_time[1]) If IsNull (lt_date) Then lt_date = Time ('12:00') ldtStart = Datetime (Date (dw_action.Object.act_dat[1]), lt_date) // durée If IsNull (dw_action.Object.dur_id[1]) Then liDur = 0 Else dw_action.GetChild ('dur_id', ldwc) ll_row = ldwc.Find ('dur_id = ' + String (dw_action.Object.dur_id[1]), 0, ldwc.Rowcount ()) Choose Case ldwc.GetItemString (ll_row, 'dur_type') Case 'SECONDES' liDur = Round (ldwc.GetItemNumber (ll_row, 'dur_longueur') / 60, 0) Case 'MINUTES' liDur = ldwc.GetItemNumber (ll_row, 'dur_longueur') Case 'HEURES' liDur = ldwc.GetItemNumber (ll_row, 'dur_longueur') * 60 Case 'JOURS' liDur = ldwc.GetItemNumber (ll_row, 'dur_longueur') * 1440 End Choose End If // alarme If dw_action.Object.act_ind_alarme[1] = 'O' Then liRemindBefore = Long (dw_action.Object.act_alarme[1]) ; If IsNull (liRemindBefore) Then liRemindBefore = 0 Else liRemindBefore = 0 End If // ************************************** // * CREATE a meeting // ************************************** ole_item = create OLEObject // Problème : la propriété [actid] doit IMPÊRATIVEMENT exister pour que ce script fonctionne // création d'un événement Outlook -> il faut trouver le moyen de rechercher si l'événement n'existe pas déjà ole_item = ole_space.GetDefaultFolder(olFolderCalendar).Items.Find('[actid]=' + String (dw_action.object.act_id[1])) If IsNull (ole_item) Then ole_item = ole_Outlk.CreateItem (olAppointmentItem) // look If userproperty pmiX EXISTS, Create If Not ll_count = ole_item.UserProperties.Count Ole_Property = CREATE OLEObject alreadyDone = False For Cx = 1 To ll_count If ole_item.UserProperties (Cx).name = "actid" Then AlreadyDone = True ole_Property = ole_item.UserProperties (Cx) Exit End If Next // Direct storing does Not work ! If Not alreadyDone Then ole_Property = ole_item.UserProperties.Add ("actid", 1, string(dw_action.object.act_id[1])) // type texte = 1 ; integer = 20 ole_Property.value = string(dw_action.object.act_id[1]) // mise en place des valeurs dans l'événement ole_item.MeetingStatus = olMeeting ole_item.Subject = lsSubject ole_item.Location = lsLoc ole_item.Body = lsBody ole_item.Start = ldtStart ole_item.AllDayEvent = False If liDur > 0 then ole_item.Duration = liDur If liDur = 1440 Then ole_item.AllDayEvent = true End If If liRemindBefore > 0 Then ole_item.ReminderSet = True ole_item.ReminderMinutesBeforeStart = liRemindBefore Else ole_item.ReminderSet = False End If ole_recip = CREATE OLEObject recopie des commerciaux liés à l'action (à l'exception de l'utilisateur connecté) If dw_action.Object.com_id[1] <> gl_comid Then ll_comid = dw_action.Object.com_id[1] select uti_e_mail INTO :lsMail FROM commercial c, utilisateur u where c.com_id = :ll_comid AND u.uti_id = c.uti_id; ole_recip = ole_item.Recipients.Add (lsMail, ole_outlk.OlMeetingRecipientType.olRequired) // ole_recip.Type = ole_outlk.OlMeetingRecipientType.OlRequired ole_recip.Resolve End If For ll_row = 1 To dw_en_copie.RowCount () If dw_en_copie.Object.com_id[ll_row] = gl_comid Then continue ll_comid = dw_en_copie.Object.com_id[ll_row] select uti_e_mail INTO :lsMail FROM commercial c, utilisateur u where c.com_id = :ll_comid AND u.uti_id = c.uti_id; ole_recip = ole_item.Recipients.Add (lsMail, ole_outlk.OlMeetingRecipientType.olOptional) // ole_recip.Type = ole_outlk.OlMeetingRecipientType.olOptional // olRequired ole_recip.Resolve Next // recopie de l'interlocuteur //If Not IsNull (dw_action.Object.itl_e_mail[1]) Then // lsMail = dw_action.Object.itl_e_mail[1] // ole_recip = ole_item.Recipients.Add (lsMail) // ole_recip.Type = ole_outlk.OlMeetingRecipientType.olRequired // ole_recip.Resolve //End If ole_item.Save //ole_item.Send ole_item.Close (0) ole_outlk.DisConnectObject () Destroy ole_outlk Destroy ole_space Destroy ole_item Destroy ole_Property Destroy ole_recip
Hors ligne
tu as reussi à avancer dans tes recherches ?
désolé de ne pas pouvoir apporter plus d'éléments.
Hors ligne
J'ai, a priori, réussi.
Résultat :
Pour créer un événement :
// I want To pass meetings info FROM pb application To ms outlook calendar. // It works For creation, but i also want To Update If modified IN pb applic. // Therefore i need To store mykey somewhere IN This calendar RECORD. // I have add a field IN outlook IN which i intend To store mykey. // The creation OF the userfield works well (i can see it with outlookspy) but WHEN i want To store an info IN it, nothing happens. (no info, but no errors mentionned) // // If i Update This outlook userfield it through outlookspy, it works: i can store And later ON Retrieve through pb This Keyid // // I checked ON different newsgroup, And did Not Find the error IN my syntax. // // This IS the piece OF code used AS prototype: SetPointer (HourGlass!) Constant Integer olFolderCalendar = 9 // OL DEFAULT metting parameters Long olAppointmentItem = 1, & olMeeting = 1, & ll_row, & ll_ActId Integer li_return String lsSubject, lsBody, lsLoc, lsType, lsMail, tmp Datetime ldtstart Time lt_date Integer lidur, liRemindBefore Long ll_count, Cx, ll_ComId Boolean alreadyDone DataWindowChild ldwc If al_row <= 0 Then Return False ll_ActId = adw_action.Object.act_id [al_row];If IsNull (ll_ActId) Then Return False OLEObject ole_outlk, ole_space, ole_item, ole_property ole_outlk = CREATE OLEObject li_return = ole_outlk.ConnectToNewObject ("outlook.application") ole_space = CREATE OLEObject ole_space = ole_outlk.GetNameSpace ("MAPI") // ************************************** // * SET Parms // ************************************** lsSubject = adw_action.Object.act_obj [al_row];If IsNull (lsSubject) Then lsSubject = '' lsLoc = adw_action.Object.act_lieu [al_row];If IsNull (lsLoc) Then lsLoc = '' // contenu du corps de l'événement lsBody = '' // société concernée lsBody += 'Société : ' + adw_action.Object.cli_soc [al_row] + ' ' + adw_action.Object.cli_compte [al_row] + '~r~n' lsBody += 'Adresse :' If Not IsNull (adw_action.Object.cli_adr1_soc [al_row]) Then lsBody += ' ' + adw_action.Object.cli_adr1_soc [al_row] If Not IsNull (adw_action.Object.cli_adr2_soc [al_row]) Then lsBody += ' ' + adw_action.Object.cli_adr2_soc [al_row] If Not IsNull (adw_action.Object.cli_adr3_soc [al_row]) Then lsBody += ' ' + adw_action.Object.cli_adr3_soc [al_row] If Not IsNull (adw_action.Object.cli_codpost_soc [al_row]) Then lsBody += ' ' + adw_action.Object.cli_codpost_soc [al_row] If Not IsNull (adw_action.Object.cli_bdi_soc [al_row]) Then lsBody += ' ' + adw_action.Object.cli_bdi_soc [al_row] If Not IsNull (adw_action.Object.pay_lbl [al_row]) And Upper (adw_action.Object.pay_lbl [al_row]) <> 'FRANCE' Then lsBody += ' ' + adw_action.Object.pay_lbl [al_row] lsBody += '~r~n' If Not IsNull (adw_action.Object.cli_tel [al_row]) Then lsBody += 'Téléphone : ' + adw_action.Object.cli_tel [al_row] + '~r~n' If Not IsNull (adw_action.Object.cli_fax [al_row]) Then lsBody += 'Fax : ' + adw_action.Object.cli_fax [al_row] + '~r~n' lsBody += '~r~n' // contact lsBody += 'Contact : ' + adw_action.Object.civ_court [al_row] + ' ' + adw_action.Object.itl_nom [al_row] If IsNull (adw_action.Object.itl_prenom [al_row]) Then lsBody += '~r~n' Else lsBody += ' ' + adw_action.Object.itl_prenom [al_row] + '~r~n' If Not IsNull (adw_action.Object.telephone [al_row]) Then lsBody += 'Téléphone : ' + adw_action.Object.telephone [al_row] + '~r~n' If Not IsNull (adw_action.Object.fax [al_row]) Then lsBody += 'Fax : ' + adw_action.Object.fax [al_row] + '~r~n' If Not IsNull (adw_action.Object.itl_tel_mob [al_row]) Then lsBody += 'Mobile : ' + adw_action.Object.itl_tel_mob [al_row] + '~r~n' If Not IsNull (adw_action.Object.itl_e_mail [al_row]) Then lsBody += 'Courriel : ' + adw_action.Object.itl_e_mail [al_row] + '~r~n' If Not IsNull (adw_action.Object.fnc_lbl [al_row]) Then lsBody += 'Fonction : ' + adw_action.Object.fnc_lbl [al_row] + '~r~n' // commentaire If Not IsNull (adw_action.Object.cac_cmt [al_row]) Then lsBody += '~r~nObjet : ' + f_mise_en_forme (adw_action.Object.cac_cmt [al_row]) // Date de début lt_date = Time (adw_action.Object.date_time [al_row]) If IsNull (lt_date) Then lt_date = Time ('12:00') ldtStart = Datetime (Date (adw_action.Object.act_dat [al_row]), lt_date) // Type d'action adw_action.GetChild ('tac_id', ldwc) ll_row = ldwc.Find ('tac_id = ' + String (adw_action.Object.tac_id [al_row]), 0, ldwc.RowCount ()) lsType = ldwc.GetItemString (ll_row, 'tac_lbl') // durée If IsNull (adw_action.Object.dur_id [al_row]) Then liDur = 0 Else adw_action.GetChild ('dur_id', ldwc) ll_row = ldwc.Find ('dur_id = ' + String (adw_action.Object.dur_id [al_row]), 0, ldwc.RowCount ()) Choose Case Upper (ldwc.GetItemString (ll_row, 'dur_type')) Case 'SECONDES' liDur = Round (ldwc.GetItemNumber (ll_row, 'dur_longueur') / 60, 0) Case 'MINUTES' liDur = ldwc.GetItemNumber (ll_row, 'dur_longueur') Case 'HEURES' liDur = ldwc.GetItemNumber (ll_row, 'dur_longueur') * 60 Case 'JOURS' liDur = ldwc.GetItemNumber (ll_row, 'dur_longueur') * 1440 End Choose End If // alarme If adw_action.Object.act_ind_alarme [al_row] = 'O' Then liRemindBefore = Long (adw_action.Object.act_alarme [al_row]);If IsNull (liRemindBefore) Then liRemindBefore = 0 Else liRemindBefore = 0 End If // ************************************** // * CREATE a meeting // ************************************** ole_item = CREATE OLEObject ole_item = ole_Outlk.CreateItem (olAppointmentItem) // look If userproperty pmiX EXISTS, CREATE If Not ll_count = ole_item.UserProperties.COUNT Ole_Property = CREATE OLEObject ole_item = ole_space.GetDefaultFolder (olFolderCalendar).Items.Find ('[actid] = ' + String (ll_ActId)) If IsNull (ole_item) Then ole_item = ole_Outlk.CreateItem (olAppointmentItem) alreadyDone = False For Cx = 1 To ll_count If ole_item.UserProperties (Cx).name = "actid" Then AlreadyDone = True ole_Property = ole_item.UserProperties (Cx) Exit End If Next If AlreadyDone Then ole_item.UserProperties (Cx).value = String (ll_ActId) Else ole_Property = ole_item.UserProperties.Add ("actid", 1, String (ll_ActId)) // Type texte = 1;Integer = 20 End if ole_Property.value = String (ll_ActId) ll_count = ole_item.ItemProperties.COUNT For Cx = 1 To ll_count tmp = "execute pc_log ('" + ole_item.ItemProperties (Cx).name + "')" execute immediate :tmp; Next // mise en place des valeurs dans l'événement ole_item.MeetingStatus = olMeeting ole_item.Subject = lsSubject ole_item.Location = lsLoc ole_item.BODY = lsBody ole_item.Start = ldtStart ole_item.Categories = lsType ole_item.AllDayEvent = False If liDur > 0 Then ole_item.Duration = liDur If liDur = 1440 Then ole_item.AllDayEvent = True End If If liRemindBefore > 0 Then ole_item.ReminderSet = True ole_item.ReminderMinutesBeforeStart = liRemindBefore Else ole_item.ReminderSet = False End If ole_item.Save ole_item.Close (0) ole_outlk.DisConnectObject () Destroy ole_outlk Destroy ole_space Destroy ole_item Destroy ole_Property Return True
Pour supprimer l'événement correspondant :
// I want to pass meetings info from pb application to ms outlook calendar. // It works for creation, but i also want to update if modified in pb applic. // Therefore i need to store mykey somewhere in this calendar record. // I have add a field in outlook in which i intend to store mykey. // The creation of the userfield works well (i can see it with outlookspy) but when i want to store an info in it, nothing happens. (no info, but no errors mentionned) // // If i update this outlook userfield it through outlookspy, it works: i can store and later on retrieve through pb this Keyid // // I checked on different newsgroup, and did not find the error In my syntax. // // This is the piece of code used as prototype: SetPointer (HourGlass!) //OlDefaultFolders Constant Integer olFolderCalendar = 9 // OL DEFAULT metting parameters Long olAppointmentItem = 1 Integer li_return Long ll_count, Cx Boolean alreadyDone = False IF IsNull (al_ActId) Then Return True OLEObject ole_outlk, ole_space, ole_item ole_outlk = CREATE OLEObject li_return = ole_outlk.ConnectToNewObject ("outlook.application") ole_space = CREATE OLEObject ole_space = ole_outlk.GetNameSpace ("MAPI") // ************************************** // * CREATE a meeting // ************************************** ole_item = create OLEObject ole_item = ole_space.GetDefaultFolder(olFolderCalendar).Items.Find('[actid]=' + String (al_ActId)) If IsNull (ole_item) Then Goto fin ole_item.Delete ole_outlk.DisConnectObject () fin: Destroy ole_outlk Destroy ole_space Destroy ole_item Return True
Dernière modification par PhPairon (17-03-2008 12:57:53)
Hors ligne
merci pour tes precieuses infos...
Hors ligne