views:

71

answers:

1

Hi my name is what, my name is who.. ops got carried away

Now this might be a serverfault question and a stackoverflow question but I will go with it here because I don't really know the answer.

I been sending mail a lot with asp.net before and never had problems like this before. I have setup a mail with this following code

var list = new List<string> { "mail", "mail", "mail", "mail" };

        var smtp = new SmtpClient("localhost", 25);
        var plainText = txtPlain.Text;
        var htmlText = Server.HtmlDecode(FCKeditor1.Value);

        foreach (var email in list)
        {
            var message = new MailMessage()
                          {
                              From = new MailAddress("my server mail"),
                              ReplyTo = new MailAddress("mail")
                          };

            var mailMessage = Server.HtmlDecode(FCKeditor1.Value);
            message.To.Add(email);
            message.Subject = "title";
            message.Body = mailMessage;
            message.IsBodyHtml = true;
            message.BodyEncoding = System.Text.Encoding.GetEncoding("iso-8859-2");

            var alternateViewHtml = AlternateView.CreateAlternateViewFromString(htmlText, null, MediaTypeNames.Text.Html);
            var alternateViewPlainText = AlternateView.CreateAlternateViewFromString(plainText, null, MediaTypeNames.Text.Plain);

            message.AlternateViews.Add(alternateViewHtml);
            message.AlternateViews.Add(alternateViewPlainText);

            smtp.Send(message);
        }

now the issue becomes that some email clients get just plain while some get the html. Like on my hotmail on the computer i get the html but on my iphone i get the plain one. Why is that?

and like that wasn't enough The mail wont deliver to some mails like any .pl email. Now here is where I am thinking that it might be a reverse DNS setup thing on my windows server 2008 issue , i had same issue with hotmail but that was solved when I added the plain. Anybody have had the problem before?

I am very thankful for any answer I get.. thanks

EDIT some company mails, it becomes spam / Got answer gone look it up, please feel free to inform me more

+1  A: 

You put a HTML Version of the Message in the Message.Body and set the IsBodyHtml = true So why are you duplicating the html component a second time, buy sending a HTML Alternative view... I think this might be redundant. try removing the two lines

        message.Body = mailMessage;
        message.IsBodyHtml = true;

Also, double check those MediaTypeNames.Text.PROPERTY values and ensure they are returning text/plain and text/html

http://www.andreas-kraus.net/blog/tips-for-avoiding-spam-filters-with-systemnetmail/

Eoin Campbell
It was just a mistype by me when I put the code on here, I did remove that. thanks for the link and tip
Dejan.S