MailMessage
This class contains information about an email message.
Parameters
string textPath
The file system path to the RFC822 text of the message. Open this to access the message text.
As from V7.2 the ReadHeader and OpenBody methods should be used.
string envelopePath
The file system path to the envelope of the message. The first line of the file is the envelope FROM, subsequent lines are the envelope TO lines. As from V7.2 the sender and recipients properties should be used.
string sender
[new for 7.2] The envelope email address used to send the email. This may not be equal to the message FROM field. It may also be blank if the message is a system message with no sender.
List<string> recipients
[new for 7.2] A list containing one or more email address of the recipients of the message.
For the spooler this may be more than one address, for a mailbox it will be only one address.
int length
[new for 7.2] The length of the message, including header.
Dictionary<string,string> header
[new for 7.4] Contains the parsed header field values apart from the Received lines.
e.g. message.header[“Subject”]
Methods
List<string> ReadHeader()
[new for 7.2] Returns the message header text, excluding the blank line that marks the end of the header.
void OpenBody()
[new for 7.2] Opens the message body for reading, excluding the blank line that marks the end of the header.
string ReadLine()
[new for 7.2] Returns the next message body line, or null of the end of message is reached.
void Close()
[new for 7.2] Closes the message body.
Code sample
using System;
using System.Collections.Generic;
using System.Text;
using FTGate.Framework;
using System.IO;
using System.Diagnostics;
// spooler extension example
public class SpoolerExtension : SpoolBehaviour
{
public ProcessMessageReturnType OnPreProcessMessage(MailMessage message)
{
Log log = new Log();
log.Write(LogType.Normal, "Sender:" +message.sender);
for (int i=0;i<message.recipients.Count;i++)
log.Write(LogType.Normal, "Rcpt:" +message.recipients[i]);
try
{
List<string> header = message.ReadHeader();
for (int i = 0; i < header.Count; i++)
log.Write(LogType.Normal, "hdr:"+header[i]);
log.Write(LogType.Normal, "-----------------");
message.OpenBody();
string s;
while ((s = message.ReadLine()) != null)
log.Write(LogType.Normal, "txt:" + s.TrimEnd());
message.Close();
}
catch (Exception ex)
{
// do nothing we just want to not crash the system
}
//BounceRenotification(message);
return ProcessMessageReturnType.Continue;
}
}