MCFBodyPart Class Methods

In the following, we discuss the MCFBodyPart class methods. The methods are described in alphabetical order.

Syntax

AddHeader(HeaderName, HeaderValue)

Description

Use the AddHeader method to add a header to the body part. This method allows for email server customizations. Some commonly used headers are already exposed as properties, such as 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

Field or Control

Definition

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

GetHeader(HeaderName)

Description

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

This method is primarily used with inbound email messages.

Parameters

Field or Control

Definition

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

Field or Control

Definition

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.

This method is primarily used with inbound email messages.

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

Field or Control

Definition

Index

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

Returns

An array of string.

Syntax

GetUnparsedHeaders()

Description

Use the GetUnparsedHeaders method to return all of the headers in the body part without any formatting occurring.

Parameters

None.

Returns

A string containing the headers.

Syntax

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

Description

Use the SetAttachmentContent method to specify the body (content) of this body part from a file.

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.

Parameters

Field or Control

Definition

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.

Example

The following uses an absolute path to set the content:

&image.SetAttachmentContent("///file:C:/User/Documentum/XML%20Applications/proddoc/peoplebook_upc/peoplebook_upc.dtd",
 %FilePath_Absolute, "sample.jpg", "This is a sample image!", "", "");

The following uses a relative path to set the content:

&attach1.SetAttachmentContent("Ocean Wave.jpg", %FilePath_Relative, 
"Ocean Wave.jpg", "Ocean Wave", "", "");

The following uses a URL to set the content:

&attach1.SetAttachmentContent("http://www.yahoo.com/members_agreement",
 %FilePath_Absolute, "hotmail.htm", "Hotmail Home page", "", "");