MCFOutboundEmail Class Methods

In this section, we discuss the MCFOutboundEmail class methods. The methods are discussed in alphabetical order.

Syntax

AddAttachment({FilePath | FileURL}, FilePathType, FileName, FileDescr, OverrideContentType, OverrideCharset)

Description

Use the AddAttachment method to add an attachment to this email.

Use the FilePathType parameter to specify if the file path is relative or absolute. If it's an absolute path, the file path could be a file on the local machine, a network folder, or a fully-qualified URL.

You can also add an attachment by creating a multipart object, adding the attachments as bodyparts to the multipart object, and then setting the MultiPart property of the MCFOutbounEmail object. The AddAttachment method is provided for convenience.

Parameters

Parameter

Description

FilePath | FileURL

You can either specify the file path to the file, or a URL to the file.

Depending on the FilePathType parameter, you may specify either a relative or absolute file path to the file.

This parameter should include the file name and extension of the file.

If you specify a URL address where the file is located, it must be an absolute URL. This URL should include the actual name of the file. If you specify a URL address, you must specify the FilePathType parameter as %FilePath_Absolute.

FilePathType

Specify the path type for the file, whether it is an absolute or relative path. The values are:

  • %FilePath_Absolute — the file path is an absolute path.

  • %FilePath_Relative — the file path is a relative path.

FileName

Specify the name of the file that you want to attach, as a string. You must include the file extension as well.

Description

Specify a description of the file.

OverrideContentType

The system detects the content type of the attachment using the file location and name. Specifying OverrideContentType overrides the system detected content type.

The character set can also be included in the ContentType. For example, “text/plain; charset=US-ASCII”

OverrideCharset

Specify a character set to be used to override the existing character set.

Returns

None.

Syntax

AddHeader(HeaderName, HeaderValue)

Description

Use the AddHeader method to add a header to the email. This method allows for email server customizations. Some commonly used headers are already exposed as properties, such as From, To, Subject, ContentType and ContentLanguage. Advanced applications can adapt this technique to meet their own requirements. These headers can be either standard SMTP headers or custom headers starting with "X-".

Parameters

Parameter

Description

HeaderName

Specify the name of the header that you want to add. This parameter takes a string value.

HeaderValue

Specify the actual text of the header, as a string.

Returns

None.

Example

   Local PT_MCF_MAIL:MCFOutboundEmail &email = create PT_MCF_MAIL:MCFOutboundEmail();
   Local string &TestName = "Custom Header";
   
   &email.From = &def.From;
   &email.Recipients = &def.Recipients;
   &email.SMTPServer = &def.SMTPServer;
   &email.Subject = &TestName;
   &email.Text = &TestName;
   
   &email.AddHeader("X-Mailer", "CRM Sales Application 8.9 SP2");
   &email.AddHeader("X-Mailer", "CRM Sales Application 8.9 SP3");
   &email.AddHeader("X-Mailer", "CRM Sales Application 8.9 SP4");
   
   &res = &email.Send();

Syntax

AddImportedAttachment(&emailID, &emailPartID)

Description

Use the AddImportedAttachment method to add a new attachment email part to an email, from an existing email attachment that has already been imported into the system. The attachment is identified by the email ID and email part ID passed into the method.

Parameters

Parameter

Description

&emailID

Specify the email ID to identify the attachment to be added to an email. This parameter takes an integer value.

&emailPartID

Specify the email part ID to identify the attachment to be added to an email. This parameter takes an integer value.

Returns

None.

Example

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

&email.From = &From;
&email.Recipients = &Recipients;
&email.Subject = &Subject;

Local PT_MCF_MAIL:MCFBodyPart &text = create PT_MCF_MAIL:MCFBodyPart();
&text.Text = "Hello";

Local PT_MCF_MAIL:MCFMultipart &mp = create PT_MCF_MAIL:MCFMultipart();
&mp.AddBodyPart(&text);
&email.MultiPart = ∓

&email.AddImportedAttachment(&emailID, &emailPartNum);

&res = &email.Send();

Syntax

GetErrorMsgParam(&index)

Description

Use this method to return each of the substitution strings used in the error message.

Parameters

Parameter

Description

&index

Specifies which substitution string to return from the array of substitution parameters.

Returns

A string containing the substitution parameter.

Example

Local PT_MCF_MAIL:MCFOutboundEmail &email = create PT_MCF_MAIL:MCFOutboundEmail();
For &index = 1 To &email.ErrorMsgParamsCount
   Local String &trace  = "Param" | &index | ": '" | &email.GetErrorMsgParam(&index) | "'";
End-For;

Syntax

GetHeader(HeaderName)

Description

Use the GetHeader method to return the value of the specified header.

Parameters

Parameter

Description

HeaderName

Specify the name of the header that you want to access the values for, as a string.

The matching of header names is case insensitive.

Returns

An array of string containing the header values. If the header is not present, returns an array of length zero.

Syntax

GetHeaderCount()

Description

Use the GetHeaderCount method to return the number of headers.

Parameters

None.

Returns

An integer, representing the number of headers present.

Syntax

GetHeaderName(Index)

Description

Use the GetHeaderName to return the name of the header that is located at Index.

Parameters

Parameter

Description

Index

Specify the numeric position of the header you want to access.

Returns

A string.

Syntax

GetHeaderNames()

Description

Use the GetHeaderNames method to return an array containing the names of all the headers.

Parameters

None.

Returns

An array of string.

Syntax

GetHeaderValues(Index)

Description

Use the GetHeaderValues method to return the value for the header located at the position specified by Index.

Parameters

Parameter

Description

Index

Specify the numeric position of the header whose value you want to access.

Returns

An array of string.

Syntax

Send()

Description

Use the Send method to send the email.

When you call the Send method, the following properties might be set based on the type of error:

  • InvalidAddresses

  • MessageNumber (from the PeopleTools Message Catalog)

  • MessageSetNumber (from the PeopleTools Message Catalog)

  • ValidSentAddresses

  • ValidUnsentAddresses

In addition, a list of substitution strings for the error message can be accessed by the ErrorMsgParamsCount property and the GetErrorMsgParam method.

Parameters

None.

Returns

A number indicating the status of the send. Values are:

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.

Syntax

SetSMTPParam(ParamName, ParamValue)

Description

Use the SetSMTPParam method to set parameters for the SMTP session to be used for sending the email. If you are only sending out one email, use this method. If you are sending many emails, use the SMTPSession class and set the parameters once for all the emails you are sending out.

Note: You should use this method before you use the Send method.

Note: This method is only applicable to SMTP-based outbound email. You should not use this method for HTTPS email.

Parameters

Parameter

Description

ParamName

Specify the name of the parameter you want to overwrite.

ParamValue

Specify the value for the named parameter that you want used instead of the existing value.

Returns

None.

Example

&email.setSMTPParam("mail.mime.decodetext.strict", "false");
&email.setSMTPParam("mail.mime.address.strict", "false");
&email.setSMTPParam("mail.debug, "true");