You aren't having conflicts between the MailMessage types, are you? I believe
the two types are System.Net.Mail and ...System.Web.Mail? (not sure about the
second)
Here is what my code looks like:
// ---------------------
bool ok = true;
MailAddress toMe = new MailAddress("fakeaddress@joeswelding.biz");
// txtEmail is a TextBox on the form:
MailAddress from = new MailAddress(txtEmail.Text); // from the form
System.Net.Mail.MailMessage Email =
new System.Net.Mail.MailMessage(from, toMe);
// Your host will probably be different. This is what I use on GoDaddy
SmtpClient server = new SmtpClient("relay-hosting.secureserver.net");
// txtMessage is a TextBox on the form:
string strHtmlBody = "<html><body>" + txtMessage.Text + "</body></html>";
Email.Subject = "Joe's Welding - Contact";
Email.Body = strHtmlBody;
Email.IsBodyHtml = true;
try {
server.Send(Email);
} catch (Exception err) {
Response.Write("<b>Unable to send: " + err.Message + "</b><br/>");
ok = false;
}
// ----------------------
Is this very different from what you are running?
"Marty" wrote:
Quote:
On Jun 10, 2:44 pm, Marty <marty.wass...@gmail.comwrote:
Quote:
On Jun 10, 2:26 pm, jp2msft <jp2m...@discussions.microsoft.comwrote:
Quote:
Try specifying an Encoding in your Message. I had problems with SMTP in the
past and it was solved (in part) by setting the Encoding.
Quote:
"Marty" wrote:
I'm having issues sending an email to an "@page.nextel.com" email
address. I can send to any other email address fine, but when I try
the page.nextel.com it gives me this error:
Quote:
Final-Recipient: XXXX...@page.nextel.com
Diagnostic-Code: smtp; 554 message body contains illegal bare CR/LF
characters.
Action: failed
Status: 5.0.0
Quote:
I think it has something to do with the headers that are being sent.
All I have in the subject and body is the word "test." Using this
same SMTP relay, I can get a PHP script to send an email if I strip
out all the headers. Whenever I send via MailMessage/SmtpClient it
fails. I've tried using the MailMessage.headers.clear(), but no
success.
Quote:
MailMessage mess = new MailMessage(txtFrom.Text,
txtTo.Text);
mess.Subject = "Test Message";
mess.Body = "Test Message";
mess.Headers.Add("From", txtFrom.Text);
mess.Headers.Add("To", txtTo.Text);
SmtpClient client = new SmtpClient(smtpServer, 25);
client.Send(mess);
mess.Dispose();
What encoding should I try? UTF8, Unicode, or UTF3....
>
I tried all encoding types with no luck. Here is the code I used
before the SmtpClient.Send().
>
mess.BodyEncoding = System.Text.Encoding.Unicode;
mess.SubjectEncoding = System.Text.Encoding.Unicode;
>