Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Jul 2001
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Sending an attachment in email via outlook (Access 97 SR1)

    Guru's,

    Okay, It seems like Access stumps me atleast once a day.. Here's the scoop. I've got an e-mail database that I'm working on. This database is simple. The e-mail addresses and other info about the people we e-mail to go into a simple form that links to a table.
    I've got a few unbound text boxes in a separate form that the user edits and puts his name, introduction message, and a message into. I then tell the sendmail module to email the content in those unbound text boxes.. I set it up so the mail sends them in a certain order, and viola.. the mail is sent to the folks with email addy's in the stored table.
    For all original intents and purposes, the e-mail works fine. We've been pasting copying word documents and pasting them into one of the unbound text boxes to mail documents via this database.
    Here is my problem. Now management wants to be able to send a file that they can insert into an unbound object box in the same form. They want this file to appear as an attachment in the e-mail that our clients are recieving. I don't know how to do this. Everytime I try to set it up the same way as my unbound text boxes, I just get a little bit of garble in the e-mail that it sends. Here's the code I'm using (keep in mind this is just the module, it links to other code behind forms and such).

    Intro2 is the name of the unbound Ole Object box that Im putting the file into. (FYI: I've tried putting the file in as content, as an icon, and as both linked and not linked. I'm stumped!)

    ***
    My SendMail Module - modSendMail:

    Sub SendEmail()
    On Error GoTo Errhandler
    Dim DB As Database
    Dim RS As Recordset
    Set DB = CurrentDb()
    Set RS = DB.OpenRecordset("tblEmail")
    Dim PersonSendTo As String
    gIntro = ""

    ' SendMsg = gTO & Chr(13) & Chr(13) & gWrittenBy & Chr(13) & Chr(13) & SendMsg

    Do While Not RS.EOF
    RS.Edit

    gIntro = gIntro1

    PersonSendTo = RS![Email]
    gTO = "TO: " & UCase(RS![Contact Name])
    SentMsg = gIntro & Chr(13) & gWrittenBy & Chr(13) & Chr(13) & gTO & Chr(13) & Chr(13) & SendMsg & Chr(13) & Chr(13) & gIntro2
    DoCmd.SendObject , , , PersonSendTo, , , SubjectLine, SentMsg, False
    RS![DateSend] = Now()
    RS.Update
    gTO = ""

    RS.MoveNext
    Loop

    Set RS = Nothing
    Set DB = Nothing

    Exit_sub:
    Exit Sub

    Errhandler:
    'GoTo Exit_sub
    MsgBox Err.Descript

    End Sub
    ***

    What do you think?

    ----
    Happen609
    Wasting more of your valuable time...

  2. #2
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    USA
    Posts
    379
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Sending an attachment in email via outlook (Access 97 SR1)

    Take a look at Microsoft Knowledge Base article Q161088: Using Automation to send a Microsoft Outlook Message.
    This code creates/sends a MS Outlook message with an attachment from Access. I have used it successfully.
    You will need to modify it a bit for your purpose, but the basics are there.

Posting Permissions

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