Link to home
Start Free TrialLog in
Avatar of BR
BRFlag for Türkiye

asked on

Sending email with ASP

Dear Experts,

Could you please check my code?
would it be correct to write it like this? My aim is to send emails to the mytable email list.

dim email

set con = server.CreateObject("adodb.connection")
con.open("DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&Server.MapPath("the-path-of-the-file.mdb"))
set rs0 = server.CreateObject("adodb.recordset")
                              
                              sqlcumle= "select * from mytable"
                              rs0.open sqlcumle, con, 1, 3
                              do while not rs.eof
                              email = rs0("email")
                              
msg_txt = "<table><tr><td><a href=http://www.mylinks.com.tr><img src=http://www.mylinks.com.tr/my-simple-jpeg.jpg border=0 title=title alt=alt atribute onemlidir. /></a></td></tr></table>"
      
      Set Mail = Server.CreateObject("CDO.Message")
      Mail.From = "myemail@mysite.com"
      Mail.To = email
      Mail.Bcc = "myemail@mysite.com"
      Mail.Cc = "myemail@mysite.com"
      Mail.Subject = "my subject"
      Mail.HTMLBody = msg_txt

      'On Error Resume Next
      
      Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
      Mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.myserversite.com"
      Mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10  
      Mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
      Mail.Configuration.Fields.Update
      Mail.Send
       rs0.movenext
loop
Avatar of kovilpattiBalu
kovilpattiBalu
Flag of India image

ASKER CERTIFIED SOLUTION
Avatar of jawa29
jawa29
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial