Results 1 to 3 of 3
  1. #1
    Join Date
    May 2009
    Posts
    26

    Exclamation Unanswered: sending email and sms

    hie guys i would want my application to send emails and sms how do i achieve this. please help me guys

  2. #2
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool Is your google broken?

    Easy, try this.
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  3. #3
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    Be careful about using text emails for sms. A number of phones will not display it correctly. I know this because we send sms alerts to out managers. You want to use html formatted email. An easy routine to do that is below. I did not write the original, but modified it for our sms use.

    Code:
    CREATE OR REPLACE procedure RAYDW.html_email(
        p_to            in varchar2,
        p_from          in varchar2,
        p_subject       in varchar2,
        p_text          in varchar2 default null,
        p_html          in varchar2 default null,
        p_priority      in varchar2 default '3')
    is
        l_boundary      varchar2(255) default 'a1b2c3d4e3f2g1';
        l_connection    utl_smtp.connection;
        l_body_html     clob := empty_clob;  --This LOB will be the email message
        l_offset        number;
        l_ammount       number;
        l_temp          varchar2(32767) default null;
    begin
        l_connection := utl_smtp.open_connection( 'mail.xxxxxxxxx.com', '25' );
        utl_smtp.helo( l_connection, 'mail.xxxxxxxxxx.com' );
        utl_smtp.mail( l_connection, p_from );
        utl_smtp.rcpt( l_connection, p_to );
        l_temp := l_temp || 'MIME-Version: 1.0' ||  chr(13) || chr(10);
        l_temp := l_temp || 'To: ' || p_to || chr(13) || chr(10);
        l_temp := l_temp || 'From: ' || p_from || chr(13) || chr(10);
        l_temp := l_temp || 'Subject: ' || p_subject || chr(13) || chr(10);
        l_temp := l_temp || 'Reply-To: ' || p_from ||  chr(13) || chr(10);
        l_temp := l_temp || 'X-Priority: '||p_priority ||  chr(13) || chr(10);
        l_temp := l_temp || 'Content-Type: multipart/alternative; boundary=' ||
                             chr(34) || l_boundary ||  chr(34) || chr(13) ||
                             chr(10);
        ----------------------------------------------------
        -- Write the headers
        dbms_lob.createtemporary( l_body_html, false, 10 );
        dbms_lob.write(l_body_html,length(l_temp),1,l_temp);
        ----------------------------------------------------
        -- Write the text boundary
        l_offset := dbms_lob.getlength(l_body_html) + 1;
        l_temp   := '--' || l_boundary || chr(13)||chr(10);
        l_temp   := l_temp || 'content-type: text/plain; charset=us-ascii' ||
                      chr(13) || chr(10) || chr(13) || chr(10);
        dbms_lob.write(l_body_html,length(l_temp),l_offset,l_temp);
        ----------------------------------------------------
        -- Write the plain text portion of the email
        l_offset := dbms_lob.getlength(l_body_html) + 1;
        dbms_lob.write(l_body_html,length(p_text),l_offset,p_text);
        ----------------------------------------------------
        -- Write the HTML boundary
        l_temp   := chr(13)||chr(10)||chr(13)||chr(10)||'--' || l_boundary ||
                        chr(13) || chr(10);
        l_temp   := l_temp || 'content-type: text/html;' ||
                       chr(13) || chr(10) || chr(13) || chr(10);
        l_offset := dbms_lob.getlength(l_body_html) + 1;
        dbms_lob.write(l_body_html,length(l_temp),l_offset,l_temp);
        ----------------------------------------------------
        -- Write the HTML portion of the message
        l_offset := dbms_lob.getlength(l_body_html) + 1;
        dbms_lob.write(l_body_html,length(p_html),l_offset,p_html);
        ----------------------------------------------------
        -- Write the final html boundary
        l_temp   := chr(13) || chr(10) || '--' ||  l_boundary || '--' || chr(13);
        l_offset := dbms_lob.getlength(l_body_html) + 1;
        dbms_lob.write(l_body_html,length(l_temp),l_offset,l_temp);
        ----------------------------------------------------
        -- Send the email in 1900 byte chunks to UTL_SMTP
        l_offset  := 1;
        l_ammount := 1900;
        utl_smtp.open_data(l_connection);
        while l_offset < dbms_lob.getlength(l_body_html) loop
            utl_smtp.write_data(l_connection,
                                dbms_lob.substr(l_body_html,l_ammount,l_offset));
            l_offset  := l_offset + l_ammount ;
            l_ammount := least(1900,dbms_lob.getlength(l_body_html) - l_ammount);
        end loop;
        utl_smtp.close_data(l_connection);
        utl_smtp.quit( l_connection );
        dbms_lob.freetemporary(l_body_html);
    end;
    /
    The address to send to for many of the major vendors follows.


    Alltel: phonenumber@message.alltel.com
    AT&T: phonenumber@txt.att.net
    Nextel: phonenumber@messaging.nextel.com
    Sprint: phonenumber@messaging.sprintpcs.com
    SunCom: phonenumber@tms.suncom.com
    T-mobile: phonenumber@tmomail.net
    VoiceStream: phonenumber@voicestream.net
    Verizon: phonenumber@vtext.com <============= ( for text only)
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •