Send attachment from oracle mail....

i got sample code --
CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "SendMail" AS
import java.util.*;
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
public class SendMail {
// Sender, Recipient, CCRecipient, and BccRecipient are comma-separated
// lists of addresses. Body can span multiple CR/LF-separated lines.
// Attachments is a ///-separated list of file names.
public static int Send(String SMTPServer,
String Sender,
String Recipient,
String CcRecipient,
String BccRecipient,
String Subject,
String Body,
String ErrorMessage[],
String Attachments) {
// Error status;
int ErrorStatus = 0;
// Create some properties and get the default Session;
Properties props = System.getProperties();
props.put("mail.akadia.com", SMTPServer);
Session session = Session.getDefaultInstance(props, null);
try {
// Create a message.
MimeMessage msg = new MimeMessage(session);
// extracts the senders and adds them to the message.
// Sender is a comma-separated list of e-mail addresses as per RFC822.
InternetAddress[] TheAddresses = InternetAddress.parse(Sender);
msg.addFrom(TheAddresses);
// Extract the recipients and assign them to the message.
// Recipient is a comma-separated list of e-mail addresses as per RFC822.
InternetAddress[] TheAddresses = InternetAddress.parse(Recipient);
msg.addRecipients(Message.RecipientType.TO,TheAddresses);
// Extract the Cc-recipients and assign them to the message;
// CcRecipient is a comma-separated list of e-mail addresses as per RFC822
if (null != CcRecipient) {
InternetAddress[] TheAddresses = InternetAddress.parse(CcRecipient);
msg.addRecipients(Message.RecipientType.CC,TheAddresses);
// Extract the Bcc-recipients and assign them to the message;
// BccRecipient is a comma-separated list of e-mail addresses as per RFC822
if (null != BccRecipient) {
InternetAddress[] TheAddresses = InternetAddress.parse(BccRecipient);
msg.addRecipients(Message.RecipientType.BCC,TheAddresses);
// Subject field
msg.setSubject(Subject);
// Create the Multipart to be added the parts to
Multipart mp = new MimeMultipart();
// Create and fill the first message part
MimeBodyPart mbp = new MimeBodyPart();
mbp.setText(Body);
// Attach the part to the multipart;
mp.addBodyPart(mbp);
// Attach the files to the message
if (null != Attachments) {
int StartIndex = 0, PosIndex = 0;
while (-1 != (PosIndex = Attachments.indexOf("///",StartIndex))) {
// Create and fill other message parts;
MimeBodyPart mbp = new MimeBodyPart();
FileDataSource fds =
new FileDataSource(Attachments.substring(StartIndex,PosIndex));
mbp.setDataHandler(new DataHandler(fds));
mbp.setFileName(fds.getName());
mp.addBodyPart(mbp);
PosIndex += 3;
StartIndex = PosIndex;
// Last, or only, attachment file;
if (StartIndex < Attachments.length()) {
MimeBodyPart mbp = new MimeBodyPart();
FileDataSource fds = new FileDataSource(Attachments.substring(StartIndex));
mbp.setDataHandler(new DataHandler(fds));
mbp.setFileName(fds.getName());
mp.addBodyPart(mbp);
// Add the Multipart to the message
msg.setContent(mp);
// Set the Date: header
msg.setSentDate(new Date());
// Send the message;
Transport.send(msg);
} catch (MessagingException MsgException) {
ErrorMessage[0] = MsgException.toString();
Exception TheException = null;
if ((TheException = MsgException.getNextException()) != null)
ErrorMessage[0] = ErrorMessage[0] + "\n" + TheException.toString();
ErrorStatus = 1;
return ErrorStatus;
} // End Send Class
} // End of public class SendMail
/

Assuming there is no question being asked there:
http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/maildemo_sql.txt

Similar Messages

  • Sending Attachment via oracle mail packages

    Hi,
    I am using utl_smtp and utl_tcp pacakges to send an e-mail. I would like to send an attachment through it, is this possible? and if yes how do i do it?
    Thanks.

    Jens,
    I am frequent visitor and contributor to this forum.
    About the link, I waned to try the same thing as I never tried this before and I am getting some hickups.
    May be you can help as you seem to be familiar with this subject,
    1. I down loaded the two java packages one for mail and one for activation from Java web site.
    2. Executed the down loads which provided me with mail.jar and activation.jar
    3. Zipped them again using Winzip as per Tom's suggestion(this may be where I may be doing some thing wrong).
    4. Transfered the mail.zip and activation.zip to my UNIX server and have our DBA try loading the files under SYS account. It is throwing error, following is the loading endeavor just for mail.zip, the other one just similar.
    $ loadjava -u sys/manager -o -r -v -f -noverify -synonym -g public mail.zip
    initialization complete
    loading  : mail.jar
    creating : mail.jar
    Error while creating resource mail.jar
        ORA-29547: Java system class not available: oracle/aurora/rdbms/Compiler
    resolver : 
    Error while turning off verifier
        ORA-06576: not a valid function or procedure name
    loadjava: 2 errorsAny ideas?
    I will appreciate any help in this regard.
    Thx,
    SriDHAR

  • How can I send e-mail with attachment from oracle 10g?

    How can I send email with attachment from oracle 10g?

    hi you can achieve the same thing from database tier of unix.

  • Send a file as attachement from Oracle Database

    Hi all,
    I m using Oracle 9i database with Developer 6i. I want to send (mail) a file as an attachement from oracle. Is is possible? If yes please help me on this matter.
    Best Regards,
    Hassan Raza Khan Lodhi

    go to :
    http://asktom.oracle.com/
    and search on "send mail attachment"
    You'll find several options.

  • Sending email from Oracle Forms with attachments

    Hi,
    Is there any package or option available in Oracle forms to send email with attachments?
    Your reply will be highly appreciated.
    Regds,
    noneda

    There are a couple of ways to send email (with attachements) from Oracle Forms. Check out these links to some examples.
    using OLE2 or CLIENT_OLE2 to access a mail-client via Mail-Api ( Get and set Outlook properties )
    using MAILTO in conjunction with HOST or CLIENT_HOST to "start" a mail-client ( Re: Open Microsoft Outlook new massage with TO containing the email address )
    using UTL_SMTP for database-side-mailing ( Re: Send mail with attachment )
    Hope this helps,
    Craig...

  • I can't use thunderbird 31.2.0 to send attachement from a pdf file with Acrobat PRO XI

    I can't use thunderbird 31.2.0 (Mozilla) to send attachement from a pdf file with Acrobat PRO XI. Each time, Acrobat replies (in french) : "il n'y a pas de client pour la messagerie par défaut". Thunderbird is indicated as "by default" in the list of programs of Windows.
    Even if I type my e-mail address, etc. in the account of Acrobat, it doesn't change. Each time, I have to record a PDF file in a folder and return to Thunderbird to send it as attached. It is a too long process,  compared with Windows XP with Acrobat Reader or Acrobat 5, I had before.
    Would you please help me to explain the process. My OS is Windows 8.1.
    Thank you

    Thank you for your answer.
    What i want to do : to send PDF files as attached documents in a message
    generated by thunderbird by my e-mail address [email protected] or
    another one I have.
    When I introduce my e-mail address under Edit-Preferences-Email
    Accounts, Acrobat ask the e-mail account, the password, the IMAP for
    ingoing message (and I use POP) and SMTP for outgoing messages. Even I
    introduce all the datas, it doesn't change, Acrobat is unable to send
    the message. And the process is not convenient, because I need all my
    outgoing messages be documented inside Thunderbird.
    So, I repeat my request : how can I use thenderbird as program by
    default from Acrobat or any other software ?
    Thank you for your next message.
    Jean-Luc Rongé
    Le 21-10-14 14:24, ANAND8502 a écrit :
    >
          I can't use thunderbird 31.2.0 to send attachement from a pdf
          file with Acrobat PRO XI
    created by ANAND8502 <https://forums.adobe.com/people/ANAND8502> in
    /Acrobat Installation & Update Issues/ - View the full discussion
    <https://forums.adobe.com/message/6850947#6850947>

  • Sending pdfs from Mac Mail to Outlook

    I have users that are sending pdfs from mac mail to outlook and the attachements are not going through.  All you see is the paperclip and nothing else.  This has just started happening.  I am telling the users to send emails as plain text with windows friendly attachement as well as to put the attachment in the email.  Anyone have any idea how to fix this.  There are some unhappy users.
    Thank you for the help
    Jeff

    Outlook for Mac has no option to import from Apple's Mail application. The best suggestion I can offer is that you use an IMAP account to transfer your messages.
    Get a free Gmail IMAP account from Google and connect to the account in Mail. Drag your messages into the account to copy them to the server.
    Connect to the same account in Outlook and copy your messages from the server to folders under On My Computer.
    Another option is to get a third party tool that are available online.
    One tool that I am familiar with is Apple Mail Export
    Or you can find more on
    google or
    yahoo for more results
    Hope this helps!

  • How to sending email from Oracle 6i(Forms)

    How can I send email from Oracle Forms(6i).
    I need to send email to a distribution list(multiple email addresses).

    send email of multiple email address
    [email protected],[email protected],[email protected]
    create or replace function mailout
    (sender in varchar2,
    recipient in varchar2,
    ccrecipient in varchar2,
    subject in varchar2,
    message in varchar2) return number
    is
    crlf varchar2(2) := chr(13)||chr(10);
    connection utl_smtp.connection;
    mailhost varchar2(50) := 'Add email server Ip Address here';
    header varchar2(4000);
    v_num number :=1;
    str number:=0;
    email varchar2(50);
    begin
    connection := utl_smtp.open_connection(mailhost,25);
    header := 'Date: '||to_char(sysdate,'dd mon yy hh24:mi:ss')||crlf||
    'From: '||sender||' '||crlf||
    'Subject: '||subject||crlf||
    'To: '||recipient||crlf||
    'Cc: '||ccrecipient||crlf||message;
    utl_smtp.helo(connection,mailhost);
    utl_smtp.mail(connection,sender);
    utl_smtp.rcpt(connection,recipient);
    while (instr(ccrecipient,',',1,v_num)>0) loop
    email:=substr(ccrecipient,str+1,instr(ccrecipient,',',1,v_num)-str-1);
    dbms_output.put_line(email);
    utl_smtp.rcpt(connection,email);
    str:=instr(ccrecipient,',',1,v_num);
    v_num:=v_num+1;
    end loop;
    utl_smtp.open_data(connection);
    -- utl_smtp.write_data(connection,header);
    utl_smtp.write_data(connection,'MIME-Version:1.0'||crlf||'Content-type:text/html'||crlf||header);
    utl_smtp.close_data(connection);
    utl_smtp.quit(connection);
    return 0;
    exception
    when utl_smtp.invalid_operation then
    dbms_output.put_line('Invalid Operation in SMTP transaction');
    return 1;
    when utl_smtp.transient_error then
    dbms_output.put_line('Temporary problem with sending email ');
    return 2;
    when utl_smtp.permanent_error then
    dbms_output.put_line('Permanent problem with sending email ');
    return 3;
    end;

  • TS3276 sending emails from mac mail?

    not possible to send email from mac mail since hotmail changed to outlook?

    The logo is an attachment. Anything in an email message that is not text must be sent as an attachment in order to be compliant with email protocols. But many modern email programs will automatically display the contents of some attachments. Apple Mail will display JPEGs and single-page PDFs. Presumably your correspondents are using an application that displays JPEGs but not PDFs.
    Some email programs expect attachments to come at the end of the message, not intermixed with the other contents of the message. Such an app may treat everything after the first attachment as attachments. That might cause the different behavior when additional attachments are included before the attachment in your signature.

  • How to sending email from Oracle Forms

    How to sending email from Oracle 6i(Forms)
    I need to send email to a distribution list(multiple email addresses).

    send email of multiple email address
    [email protected],[email protected],[email protected]
    create or replace function mailout
    (sender in varchar2,
    recipient in varchar2,
    ccrecipient in varchar2,
    subject in varchar2,
    message in varchar2) return number
    is
    crlf varchar2(2) := chr(13)||chr(10);
    connection utl_smtp.connection;
    mailhost varchar2(50) := 'Add email server Ip Address here';
    header varchar2(4000);
    v_num number :=1;
    str number:=0;
    email varchar2(50);
    begin
    connection := utl_smtp.open_connection(mailhost,25);
    header := 'Date: '||to_char(sysdate,'dd mon yy hh24:mi:ss')||crlf||
    'From: '||sender||' '||crlf||
    'Subject: '||subject||crlf||
    'To: '||recipient||crlf||
    'Cc: '||ccrecipient||crlf||message;
    utl_smtp.helo(connection,mailhost);
    utl_smtp.mail(connection,sender);
    utl_smtp.rcpt(connection,recipient);
    while (instr(ccrecipient,',',1,v_num)>0) loop
    email:=substr(ccrecipient,str+1,instr(ccrecipient,',',1,v_num)-str-1);
    dbms_output.put_line(email);
    utl_smtp.rcpt(connection,email);
    str:=instr(ccrecipient,',',1,v_num);
    v_num:=v_num+1;
    end loop;
    utl_smtp.open_data(connection);
    -- utl_smtp.write_data(connection,header);
    utl_smtp.write_data(connection,'MIME-Version:1.0'||crlf||'Content-type:text/html'||crlf||header);
    utl_smtp.close_data(connection);
    utl_smtp.quit(connection);
    return 0;
    exception
    when utl_smtp.invalid_operation then
    dbms_output.put_line('Invalid Operation in SMTP transaction');
    return 1;
    when utl_smtp.transient_error then
    dbms_output.put_line('Temporary problem with sending email ');
    return 2;
    when utl_smtp.permanent_error then
    dbms_output.put_line('Permanent problem with sending email ');
    return 3;
    end;

  • TS3899 When sending email from the Mail App or through other Apps, my default From: address will change when I enter a To: address.  This sometimes leads me to send the email from the wrong outgoing email account.  It is frustrating and poor design.

    When sending email from the Mail App or through other Apps on my iPad, my default From: address will change when I enter a To: address.  This sometimes leads me to send the email from the wrong outgoing email account.  It is frustrating and poor design, especially since I had already checked the From: address.
    iPad 4 running iOS 8.1.3

    3rd party email addresses have to be deleted on every synmced mac product, although I have 1and1.co.uk and my imac updatetes the mails in that account from mac mail.
    Yahoo etc is a 2 step deleting process but good to get your emails pushed when on the go.
    LJ
    http://www.facebook.com/The.Cowboy.Party

  • Open attachment from AOL mail

    when i download a attachment from AOL mail I get a message "Adobe Reader could not open (name of file) it is not a supported etc

    What is your operating system?  Reader version?
    If you download the attachment to your local disk first, then open it from there, does it open?

  • Live Demo of sending SMS from Oracle Forms.

    I've just a posted a live demo of how to develop code to call a web service to send and SMS from Oracle Forms.
    Regards
    Grant
    http://otn.oracle.com/formsdesignerj2ee
    http://groundside.com/blog/GrantRonald?title=live_demo_of_sending_an_sms_from_forms&more=1&c=1&tb=1&pb=1

    Welcome to the Oracle Forums. Please take a few minutes to review the following:
    <ul>
    <li>Before posting on this forum please read
    <li>10 Commandments for the OTN Forums Member
    <li>Announcement: Forums Etiquette / Reward Points
    </ul>
    Do anybody know about sending the sms from oracle forms.If anybody had means please send me the script...... This is a commonly asked question. Have you tried searching the forum for possible solutions? Take a look at this search result. I would also recommend you take a look at the Oracle Forms Services 11g web page and scroll down to the Oracle Forms 11g calling a web service link. This is a white paper published by Grant Ronald that specifically describes the process of sending SMS from Oracle Forms.
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • ACL error when sending email from Oracle 11g

    Hi,
    It returned something like "error...ACL security" when I tried to send email from Oracle 11g. Is there any security thing that I need to release in Oracle 11g? I used to send emails from Oracle 10g and didn't find any problem.
    Thanks.
    Andy

    In Database 11g Oracle introduced Network Access Control Lists (ACLs) to protect the database from users using the many internet-capable packages such as UTL_INADDR, UTL_HTTP, UTL_TCP, etc.
    Read all about it in the docs and look at the code demos here:
    http://www.morganslibrary.org/library.html
    under DBMS_NETWORK_ACL_...

  • Send information from Oracle DB - PI - NW 7.0 BI and viceversa

    Hello,
    I need to send information from Oracle DB to SAP NW 7.0 BI passing through a SAP PI and viceversa.
    Ho can I do that?
    I need help
    Best Regards...
    Pablo Mortera.

    As the sender is ORacle you can use a sender adapter which is JDBC in XI.
    As the receiver is BI system, try to use either Proxy or RFC or Idoc as a receiver adapter.
    Regards
    Krish

Maybe you are looking for