Forms - Emailing via Outlook

Forms - Emailing via Outlook

 

  

Hi Guru

At the moment I have the following code which successfully emails only one
address, however I would like to configure it to email multiple addresses.
All help greatly appreciated as usual.

Cheers
David

---------------------------------
Declare

/*declaration of the Outlook Object Variables*/
application ole2.OBJ_TYPE;
hMailItem ole2.OBJ_TYPE;
hRecipients ole2.OBJ_TYPE;
recipient ole2.OBJ_TYPE;

/*declaration of the argument list*/
args OLE2.LIST_TYPE;


begin
/*create the Application Instance*/
application:=ole2.create_obj('Outlook.Application');

/*create a Mail Instance by calling CreateItem Method and giving argument 0
with
it,
you can find the item types in the explanation of the CreateItem Method
(0=olMailItem,1=olAppointmentItem, ?)*/
args:=ole2.create_arglist;
ole2.add_arg(args,0);
hMailItem:=ole2.invoke_obj(application,'CreateItem',args);
ole2.destroy_arglist(args);



/*Get the Recipients property of the MailItem object:
Returns a Recipients collection that represents all the Recipients for the
Outlook item*/
args:=ole2.create_arglist;
hRecipients:=ole2.get_obj_property(hMailItem,'Recipients',args);
ole2.destroy_arglist(args);

/*Use the Add method to create a recipients Instance and add it to the
Recipients collection*/
args:=ole2.create_arglist;
ole2.add_arg(args,'david.[Email address protected]
recipient:=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)*/
ole2.set_property(recipient,'Type',1);
ole2.destroy_arglist(args);

/* put the property Type of the recipient Instance to value needed
(0=Originator,1=To,2=CC,3=BCC)*/
ole2.set_property(recipient,'Type',2);
ole2.destroy_arglist(args);

/*Resolve the Recipients collection*/
args:=ole2.create_arglist;
ole2.invoke(hRecipients,'ResolveAll',args);

/*set the Subject and Body properties*/
ole2.set_property(hMailItem,'Subject','Volumn Partner '||:d_name||'
configured.');
ole2.set_property(hMailItem,'Body','Volumn Partner '||:d_name||' was
successfully setup on '||:d_time||'. The PSOURCE ID is: '||:d_pid);

/*Save the mail*/
ole2.invoke(hMailItem,'Save',args);
ole2.destroy_arglist(args);

/*Send the mail*/
args:=ole2.create_arglist;
ole2.invoke(hMailItem,'Send',args);
ole2.destroy_arglist(args);

/*Release all your Instances*/
release_obj(application);
release_obj(hRecipients);
release_obj(recipient);
release_obj(hMailItem);

end;

--------------------------------


Systems Operations, Thus Plc.
.
. . _
www.thus.net www.demon.net
email. david.[Email address protected]
internal. 740 4156
external. 0141 566 4156
mobile. 07880 502093

Oracle LazyDBA home page