Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2012
    Posts
    1

    Unanswered: email from access database issue

    hi i have a database that i want to be able to email details from.
    i have the email generating and inputs the email address, the subject line and the text body of the email but when i try and input a field it comes up as script text

    ie "Act: " & email & Chr$(13) & _

    Public Function SendEMail()

    Dim db As DAO.Database
    Dim MailList As DAO.Recordset
    Dim MyOutlook As Outlook.Application
    Dim MyMail As Outlook.MailItem
    Dim Subjectline As String
    Dim BodyFile As String
    Dim fso As FileSystemObject
    Dim MyBody As TextStream
    Dim MyBodyText As String

    Set fso = New FileSystemObject

    Subjectline$ = "New Booking Confirmation"
    CCemail$ = "michelle@lte.com.au"

    BodyFile$ = "c:/newbooking.txt"

    BodyText$ = "A new booking has been confirmed for your show: ." & Chr$(13) & Chr$(13) & _
    "Act: " & email & Chr$(13) & _
    "Date: " & email & Chr$(13) & _
    "Venue: " & email & Chr$(13) & _
    "Address: " & email & Chr$(13) & _
    "Start: " & email & "Finish: " & email & Chr$(13) & Chr$(13) & _
    "Gross Fee: $" & " Less Commision: $" & " = Nett Fee: $" & email & Chr$(13) & _
    "Invoice Details: " & email & Chr$(13) & _
    "Comments: " & email & Chr$(13) & Chr$(13) & _
    "Please confirm your booking by return email" & Chr$(13) & Chr$(13) & _
    "Thankyou" & Chr$(13) & _
    "Lets Talk Entertainment" & Chr$(13) & _
    "Phone:02 49502828" & Chr$(13) & _
    "Email: bookings@lte.com.au"


    Set MyBody = fso.OpenTextFile(BodyFile, ForReading, False, TristateUseDefault)
    MyBodyText = MyBody.ReadAll
    MyBody.Close
    Set MyOutlook = New Outlook.Application
    Set db = CurrentDb()
    Set MailList = db.OpenRecordset("MyEmailAddresses")
    Do Until MailList.EOF

    Set MyMail = MyOutlook.CreateItem(olMailItem)
    MyMail.To = MailList("email")
    MyMail.CC = CCemail
    MyMail.Subject = Subjectline$
    MyMail.Body = BodyText$

    MyMail.Display
    MailList.MoveNext

    Loop

    Set MyMail = Nothing
    Set MyOutlook = Nothing

    MailList.Close
    Set MailList = Nothing
    db.Close
    Set db = Nothing

    End Function
    Last edited by Michelle Byfield; 03-01-12 at 21:28.

  2. #2
    Join Date
    Jul 2004
    Location
    South Dakota
    Posts
    267
    Just curious why you are using a FileSystemObject? I would just use a string and concatenate whatever you want to it and then assign that to the Body property of the MailItem object.

    Also, you could always create the body as HTML code so that you can format it all pretty. I can't remember if you have to use HTMLBody or something like that instead of just Body.

    C

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •