Creates a copy of the message.
Namespace: MailBee.MimeAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax public MailMessage Clone()
Public Function Clone As MailMessage
Return Value
Type:
MailMessageA
MailMessage object which represents the cloned message.
Remarks
The deep clone is performed, that means the fully independent copy of the message is created and there
are no shared objects between the original message and its copy.
Examples This sample demostrates that the message copy created by this method has its own copies of all internal objects.
For instance, their
Attachments collections are another objects, not just two references to the same object.
using System;
using MailBee;
using MailBee.Mime;
class Sample
{
static void Main(string[] args)
{
MailMessage msg = new MailMessage();
msg.LoadMessage(@"C:\Docs\TestMail.eml");
MailMessage newMsg = msg;
MailMessage clonedMsg = msg.Clone();
if (msg.Attachments == newMsg.Attachments)
{
Console.WriteLine("Equals");
}
else
{
Console.WriteLine("Not equals");
}
if (msg.Attachments == clonedMsg.Attachments)
{
Console.WriteLine("Equals");
}
else
{
Console.WriteLine("Not equals");
}
}
}
Imports MailBee
Imports MailBee.Mime
Module Sample
Sub Main(ByVal args As String())
Dim msg As New MailMessage
msg.LoadMessage("C:\Docs\TestMail.eml")
Dim newMsg = msg
Dim cloneMsg = msg.Clone()
If msg.Attachments Is newMsg.Attachments Then
Console.WriteLine("Equals")
Else
Console.WriteLine("Not equals")
End If
If msg.Attachments Is cloneMsg.Attachments Then
Console.WriteLine("Equals")
Else
Console.WriteLine("Not equals")
End If
End Sub
End Module
See Also