Email Looks Like Spam

Discussion in 'ASP.NET / ASP.NET Core' started by Miro, Nov 26, 2009.

  1. I have the code below to send an email to my hotmail account as a test.

    But the email - no matter where I send it, to hotmail or to my other email, it looks like SPAM / or hotmail has it "BLOCKED".

    Is there anything I need to add so it come through as a normal email?

    Thanks

    Try

    Dim strFrom As String = "[email protected]"
    Dim strTo As String = "[email protected]"
    Dim MailMsg As New MailMessage(New MailAddress(strFrom.Trim()), New MailAddress(strTo))
    MailMsg.BodyEncoding = Encoding.ASCII
    MailMsg.Subject = "looptry=" & trynumber.ToString

    MailMsg.Body = "Try#: " & trynumber.ToString & vbCrLf & _
    currentDate.ToString & vbCrLf & _
    MyOrderID.ToString

    MailMsg.Priority = MailPriority.High
    MailMsg.IsBodyHtml = False
    'Smtpclient to send the mail message
    Dim SmtpMail As New SmtpClient
    SmtpMail.Host = "localhost"
    SmtpMail.Send(MailMsg)

    Catch ex As Exception

    End Try
     
  2. mjp

    mjp

    It could be the message subject or body. "looptry" could look like someone trying to do an email exploit. Try adding some normal looking text to your subject and the body variable and see if it goes through.
     
  3. doesnt seem to be the loop try...
    here is some new code i tried

    Dim strFrom As String = Trim(txtEmailAddr.Text)
    Dim strTo As String = System.Configuration.ConfigurationManager.AppSettings("SendEmailTo")
    Dim MailMsg As New MailMessage(New MailAddress(strFrom.Trim()), New MailAddress(strTo))
    MailMsg.BodyEncoding = Encoding.ASCII
    MailMsg.Subject = txtSubject.Text

    MailMsg.Body = "From: " & Trim(txtName.Text) & " <" & Trim(txtEmailAddr.Text) & ">" & _
    vbCrLf & vbCrLf & _
    txtMessage.Text 'This is a textbox up to 255 chars
    MailMsg.Priority = MailPriority.High
    MailMsg.IsBodyHtml = False
    'Smtpclient to send the mail message
    Dim SmtpMail As New SmtpClient
    SmtpMail.Host = "localhost"
    SmtpMail.Send(MailMsg)
     
  4. Bruce

    Bruce DiscountASP.NET Staff

    Hotmail / Yahoo / GMail never really tells you why your email is being sent to the spam box.

    I tested sending from the web server to my test hotmail account, it didn't end up in the spam box. I don't think the IP of the server is blacklisted.

    The other common reasons left are:

    1) hotmail doesn't like the from address
    2) hotmail deosn't like the email content or the subject line
     
  5. Bruce,

    I would just like to comment after a couple months of emails going out.

    You seem to be correct.

    My regular mails ( non hotmail ) are just fine. Its just the hotmail accounts that mark it as spam originally.

    Thanks for you posting.

    Miro
     

Share This Page