#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Euless, TX
    Posts
    6
    Rep Power
    0

    Question Need to email results of Access query in html


    I am working on a simple log database for a coworker in my office. She has the need to pull records from an Access db and email them. I know there are various ways of doing this thru the menus in Access, but she would like to have the process automated as much as possible. So, I am stuck with the task of writing code to dynamically generate an email from the results of a query. By itself this is easy enough, but some of the information in the email needs to be hyperlinked to .pdf files on our servers and she does not want the whole path to the file displayed as the link. Is html my only option? If so how do I make Access generate html and copy/import that html as the body of an email in Outlook 2k? Are there any other solutions you can think of? Thanks for your time...

    Forgot to add...a file should not be created for the html to be stored. Should one be neccessary(sp?) it should be deleted when it's no longer needed. I am a beginner with VB and a novice programmer so go easy if the answer is obvious.
    Last edited by mccjg; July 10th, 2003 at 03:10 PM.
  2. #2
  3. No Profile Picture
    Average Intelligence
    Devshed Novice (500 - 999 posts)

    Join Date
    Apr 2003
    Location
    Ohio/Chicago
    Posts
    678
    Rep Power
    12

    damn you for bringing my work home


    man, this is all i did last week is set up 5 autogenerated emails, haha, here it is

    first I assume you posses the ability to connect to the db all on your own. Secondly, i use cdonts with vbscript, as long as you're not mass mailing it's ok, i hear it's inneficient and should be avoided if you are doing lots of emails with cdonts (hence the name, c donts


    code

    Function EmailCdonts(byval strAuthorEmail,byval strRecipientEmail,ByVal strCC, byval strSubject,byval strBody,
    ByVal intMailFormat,ByVal strAttachmentPath,ByVal intPriority)

    Dim ObjMail


    Set ObjMail = Server.CreateObject("CDONTS.NewMail")
    ' don't put set if you're using aspx

    ObjMail.FROM = strAuthorEmail
    ObjMail.TO = strRecipientEmail
    ObjMail.Cc = strCC

    ObjMail.Subject = strSubject

    ObjMail.BodyFormat = intMailFormat
    ObjMail.MailFormat = intMailFormat
    ObjMail.Body = strBody

    ' CdoHigh = 2 - Highest priority (Urgent)
    ' CdoNormal = 1 - Normal
    ' CdoLow = 0 - Lowest
    ObjMail.Importance = intPriority


    If strAttachmentPath <> "" Then
    ObjMail.AttachFile strAttachmentPath
    End If

    ObjMail.Send

    Set ObjMail= Nothing

    End Function


    see the bolded strSubject?

    when you pass this string it, make this your html code, aka all your links will look like this
    strSubject= "<a href=""http:\\www." & site & ".pdf"">click here to go there</a>"

    just remember for a " in the string to do "", that one tripped me up alot
    Last edited by unatratnag; July 10th, 2003 at 08:32 PM.
  4. #3
  5. No Profile Picture
    Average Intelligence
    Devshed Novice (500 - 999 posts)

    Join Date
    Apr 2003
    Location
    Ohio/Chicago
    Posts
    678
    Rep Power
    12

    oops


    sorry, read your email again,

    .BodyFormat Format of the message
    0=Text (default)
    1=HTML

    you'll want HTML of course
    Last edited by unatratnag; July 10th, 2003 at 08:32 PM.

IMN logo majestic logo threadwatch logo seochat tools logo