Visual basic CDO mail goes to junk

In visual basic, cdo.message sent emails goes to junkmail,how do i avoid it. i am sending a newsletter to many.
this is my code

Dim val1 As String, val3 As String, val4 As String, val5 As String
Dim email As String
Dim from_mail As String
Dim Mail_Body As String
Dim mmcdoconfig As Cdo.Configuration
Dim mgcdomsg As Cdo.Message
Dim an As New ADODB.Connection
Dim ar As New ADODB.Recordset
Dim hn As New ADODB.Recordset

Private Sub Send_Mail(from_mail As String)

Set mmcdoconfig = New Cdo.Configuration
Set mgcdomsg = New Cdo.Message
Set ar = an.Execute("select * from raj.emails")
Set hn = an.Execute("select * from raj.htmls") ' this reads html tags from the database i.e,html based mail

mmcdoconfig.Fields("Smtpserver") = "10.10.1.23" 'this is server address i have tried by putting the hostname also
mmcdoconfig.Fields("smtpserverport") = 25 'port no

mmcdoconfig.Fields("SendemailAddress") = from_email 'this is read from an ini file
mgcdomsg.Subject = val4   'this also read from ini file
mgcdomsg.MimeFormatted = True

mmcdoconfig.Load (cdoIIS)
mgcdomsg.Configuration = mmcdoconfig
           'mgcdomsg.CreateMHTMLBody val3, cdoSuppressNone  ' i tried with this also but not working
mgcdomsg.HTMLBody = ""
While Not hn.EOF
    mgcdomsg.HTMLBody = mgcdomsg.HTMLBody + hn.Fields(1).Value 'html contents fromthe database
    hn.MoveNext
Wend

While Not ar.EOF
mgcdomsg.Sender = ar.Fields(2) 'each person email address
mgcdomsg.To = ar.Fields(2)
mgcdomsg.From = from_mail

mgcdomsg.Send

ar.MoveNext
Wend

Command1.Enabled = False ' on sending mails to all person the button  is disabled

End Sub


Private Sub Command1_Click() 'onclicking the button
Call Send_Mail(val5)
End Sub

Private Sub Form_Load()
Dim x As Long
Dim ssection As String, selement As String, sdef As String, ssection1 As String, selement1 As String, sdef1 As String
Dim retbuf As String, lenbuf As Integer, f As String
an.Open "dsn=d4d; database=raj"
'upcoming statements are read from ini file
ssection = "timeanddate"
selement = "time"
sdef = ""
retbuf = String$(256, 0)
lenbuf = Len(retbuf)
f = "e:\work\v b\timer\timer.ini"
x = GetPrivateProfileString(ssection, selement, sdef, retbuf, lenbuf%, f)
val1 = Left$(retbuf, x)
selement = "date"
retbuf = String$(256, 0)
lenbuf = Len(retbuf)
x = GetPrivateProfileString(ssection, selement, sdef, retbuf, lenbuf%, f)
val2 = Left$(retbuf, x)
ssection1 = "newsletters"
selement1 = "website"
sdef = ""
retbuf = String$(256, 0)
lenbuf = Len(retbuf)
x = GetPrivateProfileString(ssection1, selement1, sdef1, retbuf, lenbuf%, f)
val3 = Left$(retbuf, x)
selement1 = "subject"
sdef = ""
retbuf = String$(256, 0)
lenbuf = Len(retbuf)
x = GetPrivateProfileString(ssection1, selement1, sdef1, retbuf, lenbuf%, f)
val4 = Left$(retbuf, x)
selement1 = "From"
sdef = ""
retbuf = String$(256, 0)
lenbuf = Len(retbuf)
x = GetPrivateProfileString(ssection1, selement1, sdef1, retbuf, lenbuf%, f)
val5 = Left$(retbuf, x)

End Sub

it's actually working but it is sending emails into my junk mail. but i want to send into inbox.
in rediffmail,when i send as a plaintext it is going into inbox.if i send a html mail its going to junk. in hotmail it always goes to junk. in yahoo it always goes to inbox.
thanks in advance

raj_msAsked:
Who is Participating?
 
RanjeetRainConnect With a Mentor Commented:
You may have to change your outgoing mail server setting in the code. The server you have specified may be an open relay server.
0
 
rinksno1Commented:
Well there is a some kind SPAm proof mechanism on the yahoo and hotmail providers (the big ones), For yahoo if you click "this is not spam" button for a mail (which incidently is in you bulk mail) then the future mails from the address will be delivered directly to your inbox rather than on your bulk mail...i guess there must be some kind of option to deliver the futrue mails to the inbox...in your service providers also.

In service providers like indiatimes you will always get the mail into the inbox what ever the case may be(HTML/PLain)...


rinks
0
 
raj_msAuthor Commented:
In yahoo, its always going into inbox. whereas in hotmail and rediffmail, its going into junk folders.
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
raj_msAuthor Commented:
i want to know how to do it by coding. i have subscribed  cwjobs to hotmail account, which comes directly to inbox. how is it possible. so y not mine goes to inbox.
0
 
RanjeetRainCommented:
There is NOTHING wrong with your code. And hence, you CAN NOT change this behaviour by coding it differently.

The mails that you are sending are being classified as SPAM, and hence they are delivering it to the "Junk" folder of the user mailbox. There is not much you can do without changing your mail/message's content, subject.

I would recommend you study the rules about SPAMMING and alter the content of your mail or its subject so that it gets thru. For your help I am giving you some *broad* ideas about why your mail might be classified as SPAM.

-> Your outgoing mail server (SMTP server) is an "Open Relay" and it has been blacklisted
-> Reciving domains have no way of tracing back your domain
-> Your email contains objectionable/filterable content
-> Your email contains content of repetitive nature which seems like a promotional mail
-> You send mails with same subject over and over again
-> You include too many names in the TO, CC or BCC list


0
 
raj_msAuthor Commented:
the mail which i am sending contains css, lot of gif and jpg, is it due to lot of images. my subject contains newletter from my organisation name. its subject is same for all the reciepents.
0
 
raj_msAuthor Commented:
Is it due to continuously sending mail, oneafter other.
0
 
raj_msAuthor Commented:
Yes, it is a promotional mail(newletter). Yes my subject is same for all the receipients. i am sending mail oneafter other, i.e, after sending to one reciepient, i am filling new receipient in to fields.

0
 
RanjeetRainCommented:
All the reasons you have specified are clear enough signs of your mail getting classified are Junk (obvious hints everywhere in your mail).
0
 
raj_msAuthor Commented:
so how do they send newletters.  so do u want me to change the subjects for each reciepient. so do u want me to leave some time after sending one mail, if so wats the function, to wait for some time(like wait in java).
0
 
RanjeetRainCommented:
That all may or may not help. A mail can be classified as SPAM due to many reasons, including your symptoms. YOu may not be able to get your mails delivered in the inbox despite sending it one-by-one or after intervals (though that will certainly reduce the chances). A sleep Function is less than 5 lines of code in VB. thats not the problem. Firstly you should try sending those messages manually as if it weere being sent programmatically, and then see if they get delivered in the inbox. If they get thru, then you should consider coding them.
0
 
raj_msAuthor Commented:
Yes u are rit so, i ll send manually and see. next i will try programmaticaly. Thanks, this could help me. i ll try this and send u the feedback
0
 
raj_msAuthor Commented:
thanks for ur idea, ur answer approached me near to the solution. when i send it manually, it is going to my inbox. so i guess it could go to if i send it continuously. so i need to know the sleep function. can u help me with that.
0
 
RanjeetRainCommented:
Something like this would be simple enough!


public sub Sleep(byval duration as integer)
  dim x as integer
  for x = 1 to duration * 10000
       doevents
  next x
end sub
0
 
raj_msAuthor Commented:
what's this duration. where is this from.

sleep(1000) is it like this.
0
 
RanjeetRainCommented:
Its not absolute. Its not is seconds or so. You have to experiment with it, what duration would be good enough for your purpose.

A better alternative woul dbe to use a Timer to fire your mail sending routine. Setup a timer on the form. Set it to 20 seconds 30 second, 10 minutes,20 minutes and see which duration helps you.
0
 
raj_msAuthor Commented:
even now its going to junk after doing it programmatically. when i send it manualy its going to inbox but programmatically after doing all the changes with sleep its going to junk
0
 
raj_msAuthor Commented:
Ok can u tell me how do i send mail using visual basic CDO through external smtp(like smtp.hotpop.com, etc)
0
 
raj_msAuthor Commented:
for the above code, ya what u told me is rit i agree with ur answer, but tell me the alternative solution(for the above question)
0
 
RanjeetRainCommented:
There is no alternative way to send SPAM and hope it will get thru. Even if there is any, sorry, I cannot give you here (read the EE membership aggrement).
0
 
raj_msAuthor Commented:
i dont want to send spam, but i wish to send a newsletter. is there any way that i can use the external smtp server  to send a mail. can u help me with the coding
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.