Free Support Forum - aspose.com

MessageId property empty after sending an email

Hi,

i'm using aspose.network release 6.6.0.0.

i'm trying to send an email and i'm trying to get the MessageId so i can use it in case of meeting cancellation.

the problem is that the MessageId property is never populated. it's always empty.

here's the snippet code base on aspose demo sample

// create instance of SMTPClient

SmtpClient client = new SmtpClient(txtMailServer.Text, txtUserName.Text, txtPassword.Text);

// get the attendees

MailAddressCollection attendees = new MailAddressCollection();

attendees.Add("myadress@company.fr");

// create instance of MailMessage for sending the invitation

MailMessage msg = new MailMessage();

// set from address

msg.From = "myadress@company.fr";

// set the attendees

msg.To = attendees;

// create instance of Calendar

Calendar cal = new Calendar(txtLocation.Text, DateTime.Now.AddHours(1), DateTime.Now.AddHours(2), myadress@company.fr, attendees);

cal.Summary = "Monthly Meeting";

cal.Description = "Please confirm your availability.";

msg.AddCalendar(cal);

// save the message and icalendar.

cal.Save(msg.MessageId + ".ics");

msg.Save(msg.MessageId + ".eml", MessageFormat.Eml);

// send the message with the meeting request

client.Send(msg);

Console.Write(msg.MessageId);

}

what i'm missing ? how can i have the MessageId ?

can you please provide a small sample in which we can send an appointment and then we send a cancellation for the same appointment ?

thanks for your help

Fady Sayegh

Hi Fady,

Thank you for inquiry.

Please call MailMessage.AddAlternateView() method instead of AddCalendar(). This would fix your problem.

msg.AddAlternateView(cal.RequestAppointment());