0

I found some topics about this thing, but I tried many ways to resolve this, but not working yet :( I received the mail but went to Junk folder.

This is my code:

MailMessage mail = new MailMessage();

SmtpClient smtpServer = new SmtpClient("<WORKING SMTP>");
smtpServer.Credentials = new System.Net.NetworkCredential("<WORKING USER NAME>", "<WORKING PASS>");
smtpServer.Port = 26; // Gmail works on this port

mail.From = new MailAddress("<SENDER MAIL>");
mail.To.Add(addressee);
mail.Subject = subject;
mail.Body = body;
mail.IsBodyHtml = true;
mail.BodyEncoding = System.Text.Encoding.GetEncoding("utf-8");

ContentType mimeType = new System.Net.Mime.ContentType("text/html");
AlternateView alternate = AlternateView.CreateAlternateViewFromString(body, mimeType);
mail.AlternateViews.Add(alternate);

smtpServer.Send(mail);
Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Gabor85
  • 107
  • 1
  • 10
  • 1
    See my answer here http://stackoverflow.com/questions/9504911/sending-email-with-php-and-ensuring-it-doesnt-get-blocked/9505137#9505137 it's quite likely that the issue is nothing to do with your code at all – Liath May 29 '14 at 12:43
  • 2
    One temporary solution is to ask the receiver to add your e-mail to their Contacts – kelsier May 29 '14 at 12:43
  • try by removing the alternate view as @Liath said in his answer all those factors also do matter. To which provider did you try sending the mails? try gmail, yahoo and all other popular ones. – Nikitesh May 29 '14 at 12:49
  • As an aside, MvcMailer makes it really easy to create and send emails. https://github.com/smsohan/MvcMailer/wiki/MvcMailer-Step-by-Step-Guide – MiniRagnarok May 29 '14 at 12:55
  • Now I just testing my application on localhost. I sent mail to myself just 6-8 times I think. The message was bad formatted, I mean "...)

    ..." etc. And wanted to resolve this. After that I wrote these things what you see above, and now the formatting is okay, but the mail is going to the junk folder. Now I'm tried something and left just the first (bad-formatted) mail sender part and now the mails going to junk folder too. But I don't really understand why. I just sent mails for myself (not for the same mail address what is the sender). Is that possible ?
    – Gabor85 May 29 '14 at 12:55

0 Answers0