[Cover] [Previous Section] [Next Section] [Index]
Current chapter: Perl MIME Utilities: MsgEntity Class
Section 47 out of 79 total sections
, Section 4 out of 4 sections in this chapter
Methods
The MsgEntity class provides the following methods.
new()
Description
Creates a new instance of a MsgEntity. Calling this method is a prerequisite for calling any other method of this class.
Synopsis
require MsgEntity;
...
$msgEntity = MsgEntity->new();
Synopsis
require MsgEntity;
...
$msgEntity = MsgEntity->new($header, $body);
Arguments
|
Argument
|
Meaning
|
$header
|
(hash reference) The initial header of the message.
|
$body
|
(string) The initial body of the message.
|
Returns
|
Value
|
Meaning
|
$self
|
Returns a reference to the MsgEntity object on success.
|
$undef
|
Returns undef if called with invalid arguments.
|
Example
$msgEntity = MsgEntity->new({ "Content-type" => "text/x-hdml" },
$hdmlDeck);
addHeader()
Description
Adds a header field to the message entity. If the header field already exists, it is overwritten.
Synopsis
require MsgEntity;
...
MsgEntity->addHeader($name, $value);
Arguments
|
Argument
|
Meaning
|
$name
|
(string) The name of the header field.
|
$value
|
(string) The value of the header field.
|
Example
$msg->addHeader("Content-location",
"http://www.foo.com/bar.cgi");
setBody()
Description
Sets the body of a message entity.
Synopsis
require MsgEntity;
...
$msg->SetBody($newBody);
Arguments
|
Argument
|
Meaning
|
$newBody
|
(string) The new body of the message entity.
|
Example
asString()
Description
Converts the message entity to a string for printing.
Synopsis
require MsgEntity;
...
$content = $msg->asString();
Returns
|
Value
|
Meaning
|
$content
|
The entire message as a single scalar string.
|
Example
$content = $msg->asString();
Caveats
On non-Unix systems, call "binmode" on a file descriptor before writing this string out to it.
[Cover] [Previous Section] [Next Section] [Index]
Current chapter: Perl MIME Utilities: MsgEntity Class
Section 47 out of 79 total sections
, Section 4 out of 4 sections in this chapter
Copyright © 1999, Unwired Planet, Inc. All rights
reserved.