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.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.
Facundo Salerno.
Thanks :)
ResponderEliminarThanks you for visiting my blog :-)
EliminarGeniooooooooooooooooooooooooooo
ResponderEliminaroh muchas gracias, me ha sido muy util
ResponderEliminarMe alegro que te haya servido :-)
Eliminar