Solved

Visual basic CDO mail goes to junk

Posted on 2004-09-10
23
539 Views
Last Modified: 2013-11-25
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

0
Comment
Question by:raj_ms
  • 13
  • 7
23 Comments
 
LVL 3

Expert Comment

by:rinksno1
ID: 12033568
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
 

Author Comment

by:raj_ms
ID: 12036521
In yahoo, its always going into inbox. whereas in hotmail and rediffmail, its going into junk folders.
0
 

Author Comment

by:raj_ms
ID: 12036530
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
 
LVL 19

Expert Comment

by:RanjeetRain
ID: 12038282
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
 

Author Comment

by:raj_ms
ID: 12040379
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
 

Author Comment

by:raj_ms
ID: 12040418
Is it due to continuously sending mail, oneafter other.
0
 

Author Comment

by:raj_ms
ID: 12040429
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
 
LVL 19

Expert Comment

by:RanjeetRain
ID: 12041632
All the reasons you have specified are clear enough signs of your mail getting classified are Junk (obvious hints everywhere in your mail).
0
 

Author Comment

by:raj_ms
ID: 12044949
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
 
LVL 19

Expert Comment

by:RanjeetRain
ID: 12045824
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:raj_ms
ID: 12047836
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
 

Author Comment

by:raj_ms
ID: 12048193
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
 
LVL 19

Expert Comment

by:RanjeetRain
ID: 12049311
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
 

Author Comment

by:raj_ms
ID: 12049486
what's this duration. where is this from.

sleep(1000) is it like this.
0
 
LVL 19

Expert Comment

by:RanjeetRain
ID: 12049512
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
 

Author Comment

by:raj_ms
ID: 12049817
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
 
LVL 19

Accepted Solution

by:
RanjeetRain earned 500 total points
ID: 12051373
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
 

Author Comment

by:raj_ms
ID: 12064598
Ok can u tell me how do i send mail using visual basic CDO through external smtp(like smtp.hotpop.com, etc)
0
 

Author Comment

by:raj_ms
ID: 12064623
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
 
LVL 19

Expert Comment

by:RanjeetRain
ID: 12065536
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
 

Author Comment

by:raj_ms
ID: 12065653
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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now