Display Name for From- To- CC and BCC

I try to create an MSG file with your sample:

' Create an instance of MailMessage class
Dim mailMsg As MailMessage = New MailMessage
' Set from, to, subject and body properties
mailMsg.From = txtFrom.Text
mailMsg.To = txtTo.Text
mailMsg.Subject = txtSubject.Text
mailMsg.TextBody = txtBody.Text
' Create an instance of MapiMessage class and pass MailMessage as argument
Dim outlookMsg As MapiMessage = MapiMessage.FromMailMessage(mailMsg)
' Path and file name where message file will be saved
Dim strMsgFile As String = "c:\temp\sample.msg"

I get an error on From and To properties, a MailAddressCollection object is required.
I did it and it's working fine but i need to add a Display Name for my email address:

SMITH John
john.smith@company.com

MailAddress.DisplayName is readonly...

How i can do that?



' save the message (msg) file
outlookMsg.Save(strMsgFile)


This message was posted using Page2Forum from Creating/Saving Outlook Message (msg) Files - Aspose.Network for .NET

Hi,

Thanks for considering Aspose.

From and To properties of MailMessage class are of type MailAddressCollection. You can add display name by using MailMessage.From.Add(MailAddress). Below is the sample code to do that.

Dim msg As MailMessage = New MailMessage()

msg.From.Add(New MailAddress("from@domain.com", "From Name"))

msg.To.Add(New MailAddress("to@domain.com", "To Name"))

You can also add multiple address by calling Add methods on MailMessage.From and To.

msg.To.Add(New MailAddress("to1@domain.com", "To1 Name"))

msg.To.Add(New MailAddress("to2@domain.com", "To2 Name"))