I am trying to forward a MSG file to new mail message but it does not work (.NET 4.0). It will save it to a new msg file, I can read properties. But it send send method does nothing:
try
{
//Instantiate an instance of license and set the license file through its path
Aspose.Email.License license = new Aspose.Email.License();
license.SetLicense(“Aspose.Email.lic”);
// create an instance of MailMessage
MailMessage msg = new MailMessage();
msg = MailMessage.Load(“C:\TestMail.msg”, MessageFormat.Msg);
// load the MIME message from a local disk file
msg.Subject = "FW: " + msg.Subject;
Console.WriteLine("Subject: "+ msg.Subject);
msg.To = MyEmailAddress;
msg.Save(“c:\message2.msg”, MessageFormat.Msg); // This works
msg.From = MyEmailAddress;
//sent Mail using SmtpClient
//Create an instance of SmtpClient Class
//declare test message as MailMessage instance
MailMessage message = new MailMessage();
[//txtFrom.Text](https://txtfrom.text/) is the sender’s address
message.From = MyEmailAddress;
[//txtTo.Text](https://txtto.text/) is the recipient’s address
message.To = MyEmailAddress;
message.Subject = “My First Mail”;
message.TextBody = “This is a Apsose Test”;
SmtpClient client = new SmtpClient();
//Specify your mailing host server
client.Host = MyRelay;
//Specify your Port #
client.Port = 25;
[//Client.Send](https://client.send/) will send this message
client.Send(msg); //This does not work???
client.Send(message); // This Works!!!
}
catch (Exception x)
{
// Show exception message
Console.WriteLine(“Error occured: {0}”, x.Message);
}
I am afraid, I am unable to replicate your said issue with Aspose.Email for .NET v1.2.0 1 Framework 4.0 assembly. Below is my sample code for your reference.
msg.Body = BodyHeader + msg.Body; msg.Headers.Clear(); // This is the trick need for existing messages msg.Subject = Subject; msg.To = MyEmailAddress; msg.Save(“c:\message2.msg”, MessageFormat.Msg); // This works msg.From = MyEmailAddress;