Home » Developer & Programmer » Forms » Through Outlook send mail & Attachment
Through Outlook send mail & Attachment [message #86217] Sun, 12 September 2004 21:37 Go to next message
Koala
Messages: 31
Registered: May 2002
Member
Dear All,

       How can send e-mail with attachment from form builder by outlook 2002 ?? Any script can be reference ??

Tks

Dicky
Re: Through Outlook send mail & Attachment [message #86223 is a reply to message #86217] Mon, 13 September 2004 00:30 Go to previous messageGo to next message
Himanshu
Messages: 457
Registered: December 2001
Senior Member
Hi,
Try this code.

HTH
Regards
Himanshu

DECLARE


OutlookApp OLE2.OBJ_TYPE;
NameSpace OLE2.OBJ_TYPE;
MailItem OLE2.OBJ_TYPE;
OLEPARAM OLE2.LIST_TYPE;
Send OLE2.OBJ_TYPE;
Attachments OLE2.OBJ_TYPE;
Attachment_dummy OLE2.OBJ_TYPE;
var1 varchar2(100);


Begin

--assign a value to the variable from the Oracle Form
-- var1 := :BLOCK5.txt5;

--but for testing, populate the variable 'by hand'
var1 := 'This is a test of Outlook from Oracle app.';

OutlookApp := OLE2.CREATE_OBJ('Outlook.Application');


OLEPARAM := OLE2.CREATE_ARGLIST;


OLE2.ADD_ARG(OLEPARAM,'MAPI');
NameSpace := OLE2.INVOKE_OBJ(OutlookApp,'GetNameSpace',OLEPARAM);
OLE2.DESTROY_ARGLIST(OLEPARAM);


OLEPARAM := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(OLEPARAM,0);
MailItem := OLE2.INVOKE_OBJ(OutlookApp,'CreateItem',OLEPARAM);
OLE2.DESTROY_ARGLIST(OLEPARAM);


OLE2.SET_PROPERTY(MailItem,'To','himan_bharadwaj@hotmail.com');
OLE2.SET_PROPERTY(MailItem,'Subject','message testing Outlook
automation from Oracle');
OLE2.SET_PROPERTY(MailItem,'Body', 'hello again '||var1);


--add an attachment
Attachments := OLE2.GET_OBJ_PROPERTY(MailItem,'Attachments');
OLEPARAM := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(OLEPARAM,'C:chris_school.txt');
Attachment_dummy := OLE2.INVOKE_OBJ(Attachments,'add',OLEPARAM);
OLE2.DESTROY_ARGLIST(OLEPARAM);


Send := OLE2.INVOKE_OBJ(MailItem,'Send');


--destroy objects
OLE2.RELEASE_OBJ(MailItem);
OLE2.RELEASE_OBJ(NameSpace);
OLE2.RELEASE_OBJ(OutlookApp);


END;
icon7.gif  Re: Through Outlook send mail & Attachment [message #198870 is a reply to message #86223] Wed, 18 October 2006 21:38 Go to previous messageGo to next message
APPLE_ZHANG
Messages: 6
Registered: October 2006
Location: CHINA
Junior Member

Hello, I'm new here.
I found and used your code here in my form just now, but it output the error message :ORA-30500... I don't know what I should do to solve the problem. Can you help me? Smile

thanks a lot ^_^

Apple
Re: Through Outlook send mail & Attachment [message #198878 is a reply to message #198870] Wed, 18 October 2006 23:05 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Dear Apple,

Welcome to the Forms community. Please post both the error code AND the error message.

Oracle Error :: ORA-30500
database open triggers and server error triggers cannot have BEFORE type

Cause
An attempt was made to create a trigger that fires before the database is open or before server errors, but these types of triggers are not supported.

Action
Do not attempt to create a trigger that fires before the database is open or before server errors.

I think your problem is not with this code but with the status of your database.

David
icon7.gif  Re: Through Outlook send mail & Attachment [message #198888 is a reply to message #198878] Thu, 19 October 2006 00:31 Go to previous messageGo to next message
APPLE_ZHANG
Messages: 6
Registered: October 2006
Location: CHINA
Junior Member

Thanks a lot for your help, David
I just used Himanshu's code above. But I can't find the error
message now, because it runs OK now. It can send mail with attachment successfully except for a warning message
from outlook: "A program is tring to automatically send e-mail on your behalf. Do you want to allow this? ...".
It's strange that I took no special measures to solve the problem ORA-30500 but it disappeared and the program works.

Thank you Smile
Apple
icon7.gif  Re: Through Outlook send mail & Attachment [message #198914 is a reply to message #198888] Thu, 19 October 2006 02:37 Go to previous messageGo to next message
APPLE_ZHANG
Messages: 6
Registered: October 2006
Location: CHINA
Junior Member

Hello, Davi,
I wonder if we can send e-mails with attachments automatically through procedures in PL/SQL? Thus, I can use a job to run the procrdure, which fuction is sending e-mails with attachments.

Apple ^_^
Thanks a lot, always...
Re: Through Outlook send mail & Attachment [message #198921 is a reply to message #198914] Thu, 19 October 2006 03:02 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Search this forum for 'mail' or 'email' and 'attachment' and you will find http://www.orafaq.com/forum/m/197123/67467/?srch=attachment#msg_197123

David
Re: Through Outlook send mail & Attachment [message #198922 is a reply to message #198921] Thu, 19 October 2006 03:16 Go to previous messageGo to next message
APPLE_ZHANG
Messages: 6
Registered: October 2006
Location: CHINA
Junior Member

OK, I'm having a try, thank you Davi Smile


Apple ^_^
thanks a lot, always...
Re: Through Outlook send mail & Attachment [message #204718 is a reply to message #86217] Tue, 21 November 2006 19:08 Go to previous messageGo to next message
honmsm
Messages: 2
Registered: March 2006
Location: Panama
Junior Member
I have just used the code kindly provided here and it has been very useful, the emails was sended well.

The only problem I am having is the warning message ["A program is trying to automatically send e-mail on your behalf. Do you want to allow this?]

I wonder if anyone can help me to get this message eliminated.

Tkanks a lot.

Re: Through Outlook send mail & Attachment [message #204719 is a reply to message #204718] Tue, 21 November 2006 19:19 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
I googled 'A program is trying to automatically send e-mail on your behalf. Do you want to allow this' and found http://www.contextmagic.com/express-clickyes/ and http://support.microsoft.com/kb/263084 Read these and see whether they fix your problem.

David
Re: Through Outlook send mail & Attachment [message #204723 is a reply to message #204719] Tue, 21 November 2006 20:33 Go to previous message
honmsm
Messages: 2
Registered: March 2006
Location: Panama
Junior Member

David,

I'll deeply check the information and I'll send you my comments after that, it seems like they will resolve my problem.

Many thanks for your help.

Miguel.
Previous Topic: i want the user not to delete the contents inside the editor?
Next Topic: Basic trigger question
Goto Forum:
  


Current Time: Fri Sep 20 12:29:36 CDT 2024