Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 343
  • Last Modified:

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
0
Braveheartli
Asked:
Braveheartli
1 Solution
 
kovilpattiBaluCommented:
0
 
jawa29Commented:
Hi

As far as I can see this code should work, the best thing to do is get the code to select one record from the database and add it to the subject then send the email to yourself, this way you'll be able to see if the data from the Access DB is ok and that the email is formatted correctly.

Jawa29
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now