1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
| DECLARE
v_destinataire VARCHAR2(4000);
/* declaration des variable object propre à Outlook */
application client_ole2.OBJ_TYPE;
hMailItem client_ole2.OBJ_TYPE;
hRecipients client_ole2.OBJ_TYPE;
recipient client_ole2.OBJ_TYPE;
/* declaration de la liste d'argument */
args client_ole2.LIST_TYPE;
msg_attch client_ole2.OBJ_TYPE;
PROCEDURE lier_fichier_joint_p (p_fichier IN VARCHAR2,
p_position IN NUMBER) IS
des VARCHAR2(80) := 'FILE_NAME';
attachment client_ole2.OBJ_TYPE;
BEGIN
args := client_ole2.CREATE_ARGLIST;
client_ole2.ADD_ARG (args, p_fichier);
attachment := client_ole2.INVOKE_OBJ (msg_attch, 'Add', args);
client_ole2.destroy_arglist (args);
client_ole2.SET_PROPERTY (attachment, 'name', des);
client_ole2.SET_PROPERTY (attachment, 'position', p_position);
client_ole2.SET_PROPERTY (attachment, 'type', 1);
client_ole2.SET_PROPERTY (attachment, 'source', p_fichier);
args := client_ole2.CREATE_ARGLIST;
client_ole2.ADD_ARG (args, p_fichier);
client_ole2.INVOKE (attachment, 'ReadFromFile', args);
client_ole2.DESTROY_ARGLIST (args);
END;
BEGIN
/* create the Application Instance*/
application := client_ole2.create_obj ('Outlook.Application');
args := client_ole2.create_arglist;
client_ole2.add_arg (args, 0);
hMailItem := client_ole2.invoke_obj (application, 'CreateItem', args);
client_ole2.destroy_arglist (args);
msg_attch := client_ole2.GET_OBJ_PROPERTY (hMailItem, 'Attachments');
-- Attacher les fichiers nécessaires
lier_fichier_joint_p(:suivi.w_fichier, 1);
IF :suivi.pj1 IS NOT NULL THEN
lier_fichier_joint_p(:suivi.pj1, 2);
END IF;
IF :suivi.pj2 IS NOT NULL THEN
lier_fichier_joint_p(:suivi.pj2, 2);
END IF;
IF :suivi.pj3 IS NOT NULL THEN
lier_fichier_joint_p(:suivi.pj3, 2);
END IF;
/* Get the Recipients property of the MailItem object:
Returns a Recipients collection that represents all the Recipients for the Outlook item */
args := client_ole2.create_arglist;
hRecipients := client_ole2.get_obj_property (hMailItem, 'Recipients', args);
client_ole2.destroy_arglist (args);
v_destinataire := NULL;
go_block ('INDIVIDU');
first_record;
LOOP
IF :individu.couriel IS NOT NULL THEN
IF :individu.choix = 'A' THEN
/* Use the Add method to create a recipients Instance and add it to the Recipients collection */
args := client_ole2.create_arglist;
client_ole2.add_arg (args, :individu.couriel);
recipient := client_ole2.invoke_obj (hRecipients, 'Add', args);
/* put the property Type of the recipient Instance to value needed (0=Originator,1=To,2=CC,3=BCC) */
client_ole2.set_property (recipient, 'Type', 3);
client_ole2.destroy_arglist (args);
IF v_destinataire IS NOT NULL THEN
v_destinataire := v_destinataire||','||:individu.couriel;
ELSE
v_destinataire := :individu.couriel;
END IF;
END IF;
END IF;
EXIT WHEN :SYSTEM.last_record = 'TRUE';
next_record;
END LOOP;
-- Passer les valeur pour mettre à jour le suivi
:suivi.destinataire := v_destinataire;
/* Resolve the Recipients collection*/
args := client_ole2.create_arglist;
client_ole2.invoke (hRecipients, 'ResolveAll', args);
/* set les propriétés Subject and Body*/
client_ole2.set_property (hMailItem, 'Subject', :suivi.objet);
client_ole2.set_property (hMailItem, 'Body', :suivi.description);
/* Sauvegarde du courriel*/
client_ole2.invoke (hMailItem, 'Save', args);
client_ole2.destroy_arglist (args);
/* Envoie du courriel*/
args:=client_ole2.create_arglist;
client_ole2.invoke (hMailItem, 'Send', args);
client_ole2.destroy_arglist (args);
/* Release all Instances*/
client_ole2.release_obj (application);
client_ole2.release_obj (hRecipients);
client_ole2.release_obj (recipient);
client_ole2.release_obj (hMailItem);
END; |
Partager