We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Adding MailAddresses only with Displayname

Hello,
i have problem adding MailAddresses. When i add some MailAddresses to a MailAddressCollection, it happens that some persons have no Mailadress in their profile but if i add them to the MailAddressCollection with: DisplayName as E-Mail I`ll get and the error: Invalid URI: The hostname could not be parsed. at msg.AddAlternateView(app.RequestApointment());

My Problem is that it must be possible to add mailaddress and names (without an @) as attendees, because Outlook will find them automaticly if onyl the name is entered.
Like: test@test.com; Tester, Test;

Here is my Code so far:

// Create attendees of the meeting
MailAddressCollection attendees = new MailAddressCollection();
foreach (string candidates in eMail)
{
// candidates can contain "tester@test.com" or “tester, test”
MailAddress address = new MailAddress(candidates, true);
attendees.Add(address);
}

senderAddress = "tester@test.com";

// Set up appointment
Appointment app = new Appointment(
location, // location of meeting like “Test ü ä ö”
startDate, // start date
endDate, // end date
new MailAddress(senderAddress), // organizer
attendees); // attendees

app.Method = AppointmentMethodType.Publish;

// Set up message that needs to be sent
MailMessage msg = new MailMessage()

// Generate some Reports and export it to PDF
EventDescription report = new EventDescription(userID, Convert.ToInt32(eventID));
MemoryStream mem = new MemoryStream();
report.ExportToPdf(mem);

// Add PDF from Stream to msg
Aspose.Email.Mail.Attachment attachment;
attachment = new Aspose.Email.Mail.Attachment(mem, “some.pdf”);
msg.Attachments.Add(attachment);


msg.From = senderAddress;
msg.To = "test@terst.com";
msg.Subject = mailSubject; // Like “test ä ü ö”
msg.Body = mailBodyPlain;
// Add meeting request to the message
msg.AddAlternateView(app.RequestApointment());

// Save msg as Stream for Responds
Stream ms = new System.IO.MemoryStream();
msg.Save(ms, MailMessageSaveType.OutlookMessageFormat);

Hi Martin,


Thank you for writing to Aspose support team.

I’m afraid to share that providing the valid email address is mandatory in the MailAddress object as the same is used for sending emails via Smtp and EWS clients as well. Also, in cases where Outlook can’t find the addresses, the address needs to be added anyways to the attendees or recipients. Please share your feedback for further assistance in this regard.

Okay thanks for the fast answer.

I get an error if i enter a invalid mail address to the MailAddress Object, thats ok i understand that behavior.
But
why is there an ignoreSmtpCheck? if i set it to true, i dont get any
error from the MailAddressCollection. Instead im getting the error when i
try to add the appointment to the Mail object. Is there no simple way to add just a String instead of an E-Mail Address e.g. “Lastname, Firstname”.
Outlook gets the Mail Address from its Addressbook for the names and i know that every name exists in the Addressbook.

Greets

Martin

Hi Martin,


At present, I can’t find any such option to set only display name in MailAddress object and have forwarded your requirements to our development team for their feedback. I’ll update you here via this thread once there is some feedback available in this regard.