Home > CmdEmail  
 
 

Send email from with attachments oracle forms via CmdEmail

Last updated 2005-10-11

CmdEmail is command line e-mail component, it can be integrated into application that developed by multiple language.

This article demonstrate how to integrate CmdEmail into oracle forms, enables oracle forms to send rich formated e-mail. Note: Since CmdEmail require Windows platform, if your forms is not running on Windows server, this article may be useless for you.

How to send mail from Oracle Forms

There several ways to send mail through oracle forms.

-- Using javabean
-- Using Ole component
-- Using utl_smtp
-- Using CmdEmail

In this page, we only introduce the last way, a simple and effective way to send email through oracle form, using the CmdEmail send mail component.

If you want to try other solutions, please refer to documents of Oracle Forms or search google for related topic.

Why CmdEmail?

  • Easy to manager
  • Support attachment
  • support email in html format; you can insert picture into email
  • Only require TCP/IP protocol installed

HOW CmdEmail WORKS

CmdEmail support command line interface, you call the program through command line. Supposed you have configed the program, you can send e-mail to somebody just use a dos command. e.g.

sendmail -to:scott@tiger.com

The CmdEmail read the e-mail addr. of recipients, and then send a blank message to the recipients. The recipients scott@tiger.com (if exists) will receive a mail sent from you.

Need to specify the subject and mail body?
Okey, please create a message file and pass the file path to CmdEmail .

The messae file includes two parts, header and body.
Header : Specify the recipients, subject, location of attachment etc.
Body Text: The content of the email.

There is a empty line between header and body. The following is an example:

to:scott@tiger.com
cc:bill@microsoft.com
subject:hello scott
attachment:http://www.lv2000.com/sendmail.htm

First line of the body.
Second line.

Save the text above to C:\temp_name.txt . Run CmdEmail again, e.g.

sendmail -m:c:\temp_name.txt

CmdEmail will read information from the message file, then send a mail to sott@tiger.com, copy to bill@microsoft.com.

Installation and Setup

  • Download latest version from www.lv2000.com
  • Decompress installation pack to the folder where you want to install the application files.
    We suggest you to install CmdEmail to windows PATH so that it can be called from any current working directory.
  • Setup your default email account settings.

How to setup e-mail account

Run this command line:

sendmail -setup

The CmdEmail Settings dialog will appear.Please input the information given to you by your Internet Service Provider (ISP) or administrator.

Your Name: Friendly name of the addresser.
Your email address: The addresser of the mail.
Outgoing SMTP server: Please refer to your ISP or network administrator.
Port of SMTP server: Default 25
Read receipt requested: For MS outlook only.
User Name: User name used to login the smtp server.
Password: Password used to identify the user.

Note: Unless your ISP have indicated that your service uses Secure Password Authentication, do not select the "my outgoing server requires authentication" check box.

 

Test the email account setting

Please do some testing after setting e-mail account.

Please use CmdEmail to send a mail manually.

CmdEmail will print error message if run into any error; the error will be saved into smerror.log

 

How to call CmdEmail from oracle form

You can call CmdEmail from oracle form through HOST built-in.

We have created an example demonstrate how to use HOST procedure to run CmdEmail. Please download the form from http://www.lv2000.com/examples/testmail.fmb

Screenshot of the form:

Sample code of sending mail via oracle forms

--How to create message file. Please use TEXT_IO to create the message file.
--How to call CmdEmail. Please use HOST procedure to run CmdEmail.

Sample code:

DECLARE
v_file_path varchar2(300);
v_sendmail_exe_path varchar2(300);
text_file text_io.file_type;
BEGIN
v_sendmail_exe_path:='D:\cmdemail\sendmail.exe' ;--TODO: Change the path
v_file_path := 'd:\emailmsg.txt' ;--TODO:

if :mailto is null then
message('Please enter the email address of the recipients');
raise form_trigger_failure;
end if;

text_file:=text_io.fopen(v_file_path,'w');
-- write header
text_io.put_line(text_file,'to:'||:mailto);
text_io.put_line(text_file,'cc:'||:copyto);
text_io.put_line(text_file,'attachment:c:\temp_file1.txt');
text_io.put_line(text_file,'attachment:c:\temp_file2.doc');
text_io.put_line(text_file,'subject:'||:subject);
text_io.put_line(text_file,'delete_the_file:yes');--delete the message file when the mail is sent successfully.
text_io.put_line(text_file,''); -- delimiter between header and body
-- write body
text_io.put_line(text_file,:mailbody);
text_io.fclose(text_file);
host(v_sendmail_exe_path||' -m:'||v_file_path,NO_SCREEN);
END ;

Troubleshotting

If you the mail is not sent to recipients, CmdEmail will log the error message to this file: smerror.log , please open the log file via notepad.exe and view the error message.

Support

Feedback, questions and bug reports are welcome and should be sent to the customer support, at support@lv2000.com.

 
 
Download Send Personally Download a trial version of CmdEmail Pro(60 KB):
 Download
Purchase Send Personally Purchase Mail Later online through a secure server with any major credit cards.
Product Home Page
Screenshots
Help
     
 
 
 
     
©2007 Lion Soft Ltd. All Rights Reserved.