MsgMessage Class
Namespace: Rebex.Mail
Assembly: Rebex.Msg.dll (version 8.0.9673)
Represents an Outlook .MSG e-mail message.
See https://www.rebex.net/msg/features/ for code snippets of common use cases.
Syntax
public class MsgMessage
Inherited Members
Examples
See https://www.rebex.net/msg/samples.aspx for ready-to-use samples.
Creating Outlook .MSG messages
// initialize new Outlook .MSG message instance
var message = new Rebex.Mail.MsgMessage();
// set some properties
message.From = "me@example.com";
message.To.Add("alice@example.com", "Alice");
message.CC.Add("bob@example.com", "Bob");
message.Bcc.Add("charlie@example.com");
message.Subject = "Rebex MSG sample";
message.SetBody(
"Plain text body",
"<b>HTML</b> body",
@"{\rtf1\ansi\ \b RTF\b0 body.}");
// save the message
message.Save(@"C:\MyData\sample.msg");
Extracting attachments from .MSG messages
// initialize new Outlook .MSG message instance
var message = new Rebex.Mail.MsgMessage();
// load message from disk
message.Load(@"C:\MyData\email.msg");
// extract attachments
foreach (var att in message.Attachments)
{
// in production, make sure the file name is suitable for saving on disk
string name = att.FileName;
att.Save(Path.Combine(@"C:\MyData\", name));
}
Constructors
| Name | Description |
|---|---|
| MsgMessage() | Initializes a new instance of Outlook .MSG e-mail message. See https://www.rebex.net/msg/features/ for code snippets of common use cases. |
Properties
| Name | Description |
|---|---|
| Attachments | Gets a collection of attachments of the message. |
| Bcc | Gets a collection of 'BCC' addresses of the message. |
| BodyHtml | Gets the HTML body of the message. |
| BodyRtf | Gets the RTF body of the message. |
| BodyText | Gets the plain text body of the message. |
| CC | Gets a collection of 'CC' addresses of the message. |
| From | Gets or sets the 'From' address of the message. Setting null value causes the 'From' address to be cleared. |
| IsDraft | Gets or sets a value indicating whether this mail is considered a draft. This value indicates whether the message can be modified in e-mail clients. |
| Properties | Gets a collection of properties of the message. |
| Sender | Gets or sets the 'Sender' address of the message. Setting null value causes the 'Sender' address to be cleared. |
| Subject | Gets or sets the subject of the message. |
| To | Gets a collection of 'To' addresses of the message. |
Methods
| Name | Description |
|---|---|
| Load(Stream) | Loads an Outlook .MSG mail message from the supplied stream. |
| Load(String) | Loads an Outlook .MSG mail message from the supplied file. |
| Save(Stream) | Saves the message to the supplied stream. |
| Save(String) | Saves the message to the supplied file. |
| SetBody(String, String, String) | Sets the body of the message. |