0 votes

I have your Example Source for Sendmail in my asp.net Page.
But it give an error by

builder.From.Add(new MailBox("alice@mail.com", "Alice"));

MailBox constructor doesnt want 2 Argument.

I have the current Mail.dll in my project.

by
What exact error message are you getting?

1 Answer

0 votes

There are 2 overloads of MailBox constructor:

public MailBox(string address)

public MailBox(string address, string name)

Both validate address property - it needs to be a valid email address.
new MailBox("a", "b") is going to throw, as "a" is not a valid email address.

If for some reason you need to create a MailBox without this validation use CreateWithoutValidation static method:

MailBox m = MailBox.CreateWithoutValidation("address");

or

MailBox m = MailBox.CreateWithoutValidation("address", "name");
by (301k points)
...