[SQL]Envoie de mail par une procedure
Bonjour,
Je voulais savoir comment on peut faire dans une procédure SQL pour lancer la commande d'envoie de mail suivante :
Code:
SNDDST TYPE(*LMSG) TOINTNET(('blabla@blabla.com')) DSTD('sujet') LONGMSG(&VAR)
Je précise que je créer ma procédure à partir de STRSQL. J'ai déjà essayer de mettre cette commande directement dans le code de ma procédure mais le problème c'est que STRSQL me fait une erreur sur TYPE(*LMSG)???
Merci d'avance
Re: [SQL]Envoie de mail par une procedure
Citation:
Envoyé par yoyopi
Code:
SNDDST TYPE(*LMSG) TOINTNET(('blabla@blabla.com')) DSTD('sujet') LONGMSG(&VAR)
Je ne pense pas que cela soit possible. Tu exécutes une commande système et non du SQL. Tu dois passer par ce qui est supporté comme language au niveau de ta procédure stockée. :wink:
Paramêtrage Iseries ou As400 pour l'envoie de Mail
Yoyopi
Ci joint une procedure pour parametré l'envoie mail natif de l'as400 via un routeur de mail. sinon si ca t'intéresse ya tjrs javamail de possible, mais le natif permet d'utiliser les emails renseigner sur les comptes utilisateurs directement via Iseries Navigator.
Pour ma part j'ai déjà utilisé les deux
Pour Info, ca peut servir a d'autre :
(le seul probléme que j'ai rencontré suite a cette conf, lors du démarrage du serveur smtp, a été d'ajouter aprés le cfgtcp option 10 pour la table host l'option 12 pour re-renseigner mon serveur de mail ainsi que son domain.)
/*===================================*/
/* How to send email from the AS/400 */
/*===================================*/
/*===================================*/
/* */
/* Author: Steve Miall */
/* Company: Genesis V */
/* Web site: http://www.genesisv.com */
/* date: 4th October 2000 */
/* */
/*===================================*/
The command EMAIL, the CL program EMAILC, and the RPG pgm XFMTEM
are used for sending emails direct from the AS/400. The idea is that
the command could be built into AS/400 applications to allow the system
to email orders, invoices, queries, etc. Please don't use it to spam
all your prospects!
This does NOT include instructions or software for receiving emails
on the AS/400.
Requirements:
1. OS/400 release 4.2 or higher!
2. Must have an SMTP gateway somwhere on your network.
The following are set-up instructions.
1. Get the IP address of the email (SMTP) gateway. This is either a PC
or network server on your network, or it is the server at your local
ISP (internet service provider). If you are set up to send email
from your PC, then it is the same IP address as the PC is using for
outgoing email.
2. Make sure this SMTP gateway is in your AS/400 hosts table:
ADDTCPHTE INTNETADR('192.168.1.50') HOSTNAME('SMTP')
If the internet address is already in the table, make a note of its
Host table name.
3. Change the SMTP attributes:
CHGSMTPA AUTOSTART(*YES) MAILROUTER('SMTP') FIREWALL(*YES)
4. Add your email users to the SMTP alias names system table.
CFGTCPSMTP then option 1.
This is the users you want to be able to send emails.
This is only so that the email gets a decent looking "from"
name, and so that email replies go to a real email account.
If you don't add an alias table, then your email will be sent from:
USER@ADDR.DOMAIN.COM where the USER and ADDR are your user ID and
Address, and DOMAIN.COM is the domain name of the AS/400.
- use WRKDIRE *ALL to see the user names registered in the
directory.
- To review or change the domain name of the 400 use the command:
CHGTCPDMN - prompt command with F4.
The alias table consists of USER ID, Address, SMTP userid and
SMTP Domain:
for example, my entry is:
USERID MYUSER
ADDRESS GVUK
SMTP user name support
SMTP Domain GENESISV.COM
With this there, my mail is sent from
support@GENESISV.COM
But without it, it is sent from
MYUSER@GVUK.GVUK.GENESISV.COM
where MYUSER=User
GVUK=Address
GVUK=Host name
GENESISV.COM=Domain
5. Add a generic user in the directory to route email:
Either WRKDIRE and take the add option, or:
ADDDIRE (INTERNET SMTPRTE) USRD('Internet generic user') +
SYSNAME(TCPIP) NETUSRID(*USRID) +
MSFSRVLVL(*USRIDX) PREFADR(NETUSRID *IBM ATCONTXT)
6. Add a distribution Queue:
ADDDSTQ DSTQ(QSMTPQ) RMTLOCNAME(TCPIP) DSTQTYPE(*RPDS)
7. Add a routing table entry:
CFGDSTSRV option 2:
Destination system
name/Group . . . . . : TCPIP
Description . . . . . : TCP/IP Routing
Service level:
Fast:
Queue name . . . . : QSMTPQ
Maximum hops . . . : *DFT
Status:
Queue name . . . . : QSMTPQ
Maximum hops . . . : *DFT
Data high:
Queue name . . . . : QSMTPQ
Maximum hops . . . : *DFT
Data low:
Queue name . . . . : QSMTPQ
8. Change the distribution attributes:
CHGDSTA KEEPRCP(*BCC) USEMSFLCL(*NO) SMTPRTE(INTERNET SMTPRTE)
9. There can be an authority problem, which can cause the MSF
facility to die. This stops all emailing AND all QSNADS message
sending, until you next ENDMSF and STRMSF.
To get round it, grant the following authorities:
GRTOBJAUT OBJ(QSYS/QZMFARSV) OBJTYPE(*PGM) USER(QTCP) AUT(*USE)
GRTOBJAUT OBJ(QSYS/QZMFARSV) OBJTYPE(*PGM) USER(QMSF) AUT(*USE)
GRTOBJAUT OBJ(QSYS/QZMFASCR) OBJTYPE(*PGM) USER(QTCP) AUT(*USE)
GRTOBJAUT OBJ(QSYS/QZMFASCR) OBJTYPE(*PGM) USER(QMSF) AUT(*USE)
GRTOBJAUT OBJ(QSYS/QZMFACHG) OBJTYPE(*PGM) USER(QTCP) AUT(*USE)
GRTOBJAUT OBJ(QSYS/QZMFACHG) OBJTYPE(*PGM) USER(QMSF) AUT(*USE)
GRTOBJAUT OBJ(QSYS/QZMFACRT) OBJTYPE(*PGM) USER(QTCP) AUT(*USE)
GRTOBJAUT OBJ(QSYS/QZMFACRT) OBJTYPE(*PGM) USER(QMSF) AUT(*USE)
10. Start the server:
STRTCPSVR *SMTP
11. Test to see if it sends:
SNDDST TYPE(*LMSG) TOUSRID((INTERNET SMTPRTE)) +
DSTD('E-mail') +
TOINTNET((me@mysystem.com')) +
SUBJECT('This is the subject') +
LONGMSG('This is the message')
and then go to your mail receiver and see if you have received
the message.
12. To send from a QDLS document:
SNDDST TYPE(*FILE) TOUSRID((INTERNET SMTPRTE)) +
TOINTNET(('me@mysystem.com')) +
DSTD('Email') +
MSG('This is a test') +
DOC(document.TXT) FLR(folder)
The subject will be the document description - the SUBJECT parameter
is accepted but ignored. The MSG parameter is optional.
You cannot have a long message with an attached document, and you
cannot attach 2 documents.
13. For now, all email recipients must be *PRI (primary send to) or
*BCC (blind copy to). Do NOT use *CC (copy to) because the
email format goes screwy - it has an extra new line character in a
crucial place which means marker for the start and end of the text
is corrupted. The recipients end up with a message saying
"your browser does not accept the format" etc.
However, you can have several *PRI (primary send to) addresses.
14. For sending emails with the data from source documents, use the
new command EMAIL, which uses the CL pgm EMAILC, and calls the
formating program XFMTEM.
This allows .a .A at the start of the line or :/P mid-line
to mean new paragraph, and :/N to mean new line.
It also gets rid of the junk at the end of a source member
which has been maintained using the old EDTTXT - in case anybody
is still using this.
15. The source is separately downloadable from this web site.
To compile:
a. CRTLIB GVEMAIL TEXT('Email source library')
b. Create source files to copy the source into:
CRTSRCPF GVEMAIL/QRPGSRC
CRTSRCPF GVEMAIL/QCLSRC
CRTSRCPF GVEMAIL/QCMDSRC
e. copy the source into the appropriate source members
in these 3 files.
f. ADDLIBLE GVEMAIL
g. CRTPF FILE(GVEMAIL/EMAIL) RCDLEN(72) TEXT('Email +
Transmision file')
h. CRTRPGPGM PGM(QUSRSYS/XFMTEM) SRCFILE(GVEMAIL/QRPGSRC) +
SRCMBR(*PGM)
i. CRTCLPGM PGM(QUSRSYS/EMAILC) SRCFILE(GVEMAIL/QCLSRC) +
SRCMBR(*PGM) TGTRLS(V4R2M0)
(higher releases will be OK too!)
j. CRTCMD CMD(QUSRSYS/EMAIL) PGM(*LIBL/EMAILC) +
SRCFILE(GVEMAIL/QCMDSRC)
18. The command is set up with some defaults which you may want to
change:
The default addressee is "support@genesisv.com". To change this
use the command
CHGCMDDFT CMD(GVEMAIL/EMAIL) NEWDFT('TO(xxx@yyy.com)')
The default source file for messages is QTEMP/QMSG. You might want
to set up a default source file for messages in a common area
and change the default to use this:
CRTSRCPF QUSRSYS/QMSG TEXT('E-mail messages')
CHGCMDDFT CMD(GVEMAIL/EMAIL) NEWDFT('FILE(QUSRSYS/QMSG)')
19. If you have problems and need any more info on setting up TCP/IP
and other related issues, try going to:
http://www.easy400.ibm.it/tcpcfgs