Solved

Help

Posted on 2007-11-20
9
324 Views
Last Modified: 2013-12-19
Hi,
   We are using oracle 9i to store or daily transactio and data. I want to send mail form from transaction when it inserted in database authomaticaly to our customers through our mailserver using vb 60.  can any one help in this regard.
0
Comment
Question by:aib_it
9 Comments
 
LVL 10

Expert Comment

by:Clif
ID: 20320863
You might want to start here...

http://www.dba-oracle.com/t_utl_smtp_utility.htm

0
 
LVL 73

Expert Comment

by:sdstuber
ID: 20322413
CREATE OR REPLACE TRIGGER trg_test_mail
BEFORE INSERT
ON your_table
FOR EACH ROW
DECLARE
    v_connection   UTL_SMTP.connection;
BEGIN
    v_connection    := UTL_SMTP.open_connection('your.smtp.server.com');
    UTL_SMTP.helo(v_connection, 'domain.com');
    UTL_SMTP.mail(v_connection, 'from@doman.com');
    UTL_SMTP.rcpt(v_connection, 'to@domain.com');
    UTL_SMTP.open_data(v_connection);
    UTL_SMTP.write_data(v_connection,
                        'From: ' || 'test from address' || UTL_TCP.crlf
                       );
    UTL_SMTP.write_data(v_connection,
                        'To: ' || 'test to address' || UTL_TCP.crlf
                       );
    UTL_SMTP.write_data(v_connection,
                        'Subject: ' || 'test subject' || UTL_TCP.crlf
                       );
    UTL_SMTP.write_data(v_connection, UTL_TCP.crlf);
    UTL_SMTP.write_data(v_connection, 'test body' || UTL_TCP.crlf);
    UTL_SMTP.close_data(v_connection);
    UTL_SMTP.quit(v_connection);
EXCEPTION
    WHEN OTHERS
    THEN
        DBMS_OUTPUT.put_line(DBMS_UTILITY.format_error_stack);
END trg_test_mail;
/
0
 
LVL 8

Expert Comment

by:LindaC
ID: 20323814
I don't understand vb, but today I found this script in a Windows server that send an attachment of a log.
The log is the product of our dily exports of the databae, but if you know vb, maybe this can help.

'Send Email With Attachments

'by Expert Forum friends

'

'Sending a text email using authentication against a remote SMTP server

Const cdoSendUsingPickup = 1 

Const cdoSendUsingPort = 2 

Const cdoAnonymous = 0

' Use basic (clear-text) authentication. 

Const cdoBasic = 1

' Use NTLM authentication 

Const cdoNTLM = 2 'NTLM

'Send attachments

Dim objEmail,AddAttch
 

Set oShell = CreateObject("wscript.shell")
 

Set objDictionary = CreateObject("Scripting.Dictionary")
 

Set objFSO = CreateObject("Scripting.FileSystemObject")
 

Set objFolder = objFSO.GetFolder("C:\oracle\admin\export\Logs\")

'Set objFolder = objFSO.GetFolder("c:\temp")
 

Set colFiles=objFolder.Files
 

i = 0
 

For Each objFile in colFiles
 

   AddAttch = objfile.name
 

   objDictionary.Add i,AddAttch
 

   i = i + 1

      

Next
 

aItems=objDictionary.Items
 

For i = 0 to objDictionary.count -1
 

   objEmail= objDictionary.Item(objItem)

' Create the message object.

Set objMessage = CreateObject("CDO.Message")

'Set the from address this would be your email address.

objMessage.From = "myemail1@hotmail.com" 

' Set the TO Address separate multiple address with a comma

objMessage.To = "myemail1@hotmail.com,myemail2@hotmail.com"

''Set the Attachments

objMessage.AddAttachment(objFolder & "\" & aItems(i))

' Set the Subject.

objMessage.Subject = "Database - Export - Coldbackup Log" 

' Now for the Message Options Part. 

' Use standared text for the body.

objMessage.TextBody = _

"Mensaje atachado .." & _

vbCRLF & _

"Acuse de Recibo"
 

' Or you could use HTML as:

' objMessage.HTMLBody = strHTML
 

' ATTACHMENT : Add an attachment Can be any valid url

'objMessage.AddAttachment("c:\temp\test.txt")
 

' This section provides the configuration information for the SMTP server.

' Specifie the method used to send messages.

objMessage.Configuration.Fields.Item _

("http://schemas.microsoft.com/cdo/configuration/sendusing") = _

cdoSendUsingPort 
 

' The name (DNS) or IP address of the machine 

' hosting the SMTP service through which 

' messages are to be sent.

objMessage.Configuration.Fields.Item _

("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "Your Smtp server ip address"
 

'Specify the authentication mechanism 

' to use. 

objMessage.Configuration.Fields.Item _

("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = _

cdoBasic
 

' The username for authenticating to an SMTP server using basic (clear-text) authentication

'objMessage.Configuration.Fields.Item _

'("http://schemas.microsoft.com/cdo/configuration/sendusername") = _

'"info@itsecdata.net"
 

' The password used to authenticate 

' to an SMTP server using authentication

'objMessage.Configuration.Fields.Item _

'("http://schemas.microsoft.com/cdo/configuration/sendpassword") = _

'"Welcome1"
 

' The port on which the SMTP service 

' specified by the smtpserver field is 

' listening for connections (typically 25)

objMessage.Configuration.Fields.Item _

("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = _

25 
 

'Use SSL for the connection (False or True)

'objMessage.Configuration.Fields.Item _

'("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = _

'False
 

' Set the number of seconds to wait for a valid socket to be established with the SMTP service before timing out.

'objMessage.Configuration.Fields.Item _

'("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = _

'60
 

' Update configuration

objMessage.Configuration.Fields.Update
 

' Use to show the message.

' MsgBox objMessage.GetStream.ReadText
 

' Send the message.

objMessage.Send
 

Next

Open in new window

0
 

Author Comment

by:aib_it
ID: 20325784
        Thanks actually when data inserts. then a veiw creats in databalse where is the required  info as
mail body text and mail address of client. now i want that to build an application which can take these information from that veiw table and send it to our smtp server.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 73

Expert Comment

by:sdstuber
ID: 20329231
you can select from that view to populate the parameters in the utl_smtp calls in the trigger
0
 

Author Comment

by:aib_it
ID: 20332508
       If there is any book or topic whhich is about sending mail to smtp server from oracle through vb
that will be more better.
0
 
LVL 73

Expert Comment

by:sdstuber
ID: 20334896
sending mail in vb wouldn't involve oracle at all.

just like sending mail from oracle doesn't involve vb.

if you don't want to do the trigger, simply pull that code out and put it in a stored procedure and then call that procedure from vb
0
 

Author Comment

by:aib_it
ID: 20349405
       Now we made that detail of each transaction saves in a folder with .doc format. And I want to send those files from that folder to our smtp server Through vb. i will try to use the above procdure for this purpose. but it will be more significant ia book or topic wich covers sending messages.files to smtp server through vb 6.0
0
 
LVL 73

Accepted Solution

by:
sdstuber earned 500 total points
ID: 20349451
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now