Mostrando entradas con la etiqueta MCFOutboundEmail. Mostrar todas las entradas
Mostrando entradas con la etiqueta MCFOutboundEmail. Mostrar todas las entradas

sábado, 7 de marzo de 2015

Sending Mails through PeopleSoft -> Bye SendMail()

Hi!

Since Tools 8.52 SendMail() has been deprecated. It was replaced by a more powerful application class PT_MCF_MAIL:MCFOutboundEmail 

As I have not seen it used frequently I decided to write this post, both for having it always in mind and for letting anyone know about it.

Here you have a practical way of using it.

1) We import the Application Class

import PT_MCF_MAIL:MCFOutboundEmail ;

2) We instantiate an object of this class

 Local PT_MCF_MAIL:MCFOutboundEmail &eMail = create PT_MCF_MAIL:MCFOutboundEmail();

3) We fill all the mail sections in the following way.

   &eMail.From = "mailFrom@server.com" ;
   &eMail.Recipients = "target1@server.com ;target2@server.com ;target3@server.com" ;
   &eMail.Subject = "This is the subject of the mail";
   &eMail.Text = "This is the content of the mail";
   
4) In case we need to attach any file, we have the AddAttachment method 
And an easy way of using it coudl be:
   &eMail.AddAttachment( &AttachmentPath+  &AttachmentNameWithExtension , %FilePath_Absolute | %FilePath_Relative, &AttachmentNameWithExtension"Attachment Description" , "", "");
   
5) As Send method  has a return value, we have 2 possibly ways of sending the mail.
  • If &eMail.Send() = %ObEmail_Delivered then
  • Local integer &i_ret = &eMail.Send();

If method returns a "1" value, everything works as expected. Otherwise, we should check it!

Numeric Value
Constant Value
Description
0
%ObEmail_ FailedBeforeSending
Email failed before being sent.
1
%ObEmail_Delivered
Email was delivered.
2
%ObEmail_NotDelivered
Email delivery not attempted.
3
%ObEmail_PartiallyDelivered
Email has only been partially delivered. Only some
of the addresses in the list of addresses were delivered to.
-1
%ObEmail_ SentButResultUnknown
Email was sent but whether it was successful or not is not known.
For further details, we can just check PeopleBooks at the following link:
http://docs.oracle.com/cd/E41633_01/pt853pbh1/eng/pt/tpcr/task_MCFOutboundEmailClass-f451c6.html

I hope this blog could be so useful to you as it is to me.

Regards.
Facundo Salerno.

Mandar mails desde PeopleSoft -> Chau SendMail()

Hola!

A partir de las tools 8.52 la función SendMail() ha sido considerada obsoleta, y fue reemplazada por una herramienta mas potente: La clase PT_MCF_MAIL:MCFOutboundEmail 

Como todavía no la encuentro muy utilizada decidí hacer este post, tanto para tenerlo siempre presente, como para cualquier curioso que todavía no la conozca.

Acá va una forma rápida de usarla:

1) Importamos la clase:

import PT_MCF_MAIL:MCFOutboundEmail ;

2) Instanciamos un objeto de la misma

 Local PT_MCF_MAIL:MCFOutboundEmail &eMail = create PT_MCF_MAIL:MCFOutboundEmail();

3) Agregamos los datos necesarios de la siguiente manera

   &eMail.From = "miCorreo@servidor.com" ;
   &eMail.Subject = "Este es el asunto del mail";
   &eMail.Text = "Este sería el texto del cuerpo del mail";
   
4) Si precisamos agregar adjuntos, tenemos el método AddAttachment
Y una breve forma de usarlo sería
   &eMail.AddAttachment( &rutaAdjunto +  &nombreAdjuntoConExtension  , %FilePath_Absolute | %FilePath_Relative, &nombreAdjuntoConExtension, "Descripción del Adjunto" , "", "");
   
5) Enviamos el mail, como nos devuelve un valor de retorno tenemos dos formas de hacerlo.
  • If &eMail.Send() = %ObEmail_Delivered then
  • Local integer &i_ret = &eMail.Send();

Si el retorno del método es 1, salió todo bárbaro... sino... a revisar!

Número
Constante de Retorno
Descripción
0
%ObEmail_ FailedBeforeSending
El correo falló antes de ser enviado
1
%ObEmail_Delivered
El correo se envió correctamente
2
%ObEmail_NotDelivered
No se pudo entregar el correo.
3
%ObEmail_PartiallyDelivered
El correo se entregó pero no a TODOS los destinatarios.
-1
%ObEmail_ SentButResultUnknown
Se envió el correo, pero se desconoce si fue entregado.
Para mas detalles de la clase, pueden simplemente ver los books relacionados al tema en el siguiente link:
http://docs.oracle.com/cd/E41633_01/pt853pbh1/eng/pt/tpcr/task_MCFOutboundEmailClass-f451c6.html

Espero que este simple Paso a Paso les resulte tan útil como a mí.

Saludos.
Facundo Salerno.