Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2005

    Unanswered: outlook email from access table

    I create some files and store their names in a table along with the email addresses of the people they are to be sent to. I have a form with a list box that allows me to verify the info and then click on a button to send the emails to every address in the table along with their respective file. I have some simplified code attached. I keep getting the compile error object required text box when it get to the line "Set strAddress = myrs![EmailAddress]" If anyone has any ideas, I would love to hear them. Thanks in advance.

    Private Sub Command17_Click()
    Dim mydb As Database
    Dim myrs As Recordset
    Dim objectoutlook As Outlook.Application
    Dim objoutlookmsg As Outlook.MailItem
    Dim objoutlookrecip As Outlook.Recipient
    Dim objoutlookattach As Outlook.Attachment
    Dim strAddress As String
    Dim strcc As String
    Dim strAttach As String
    Dim strmsg As String
    Dim strsubject As String

    Set mydb = CurrentDb
    Set myrs = mydb.OpenRecordset("tblMailingList")

    'create the outlook session'
    Set objectoutlook = CreateObject("Outlook.Application")

    'create the email message'
    Do Until myrs.EOF
    ' set the string values'
    Set objoutlookmsg = objectoutlook.CreateItem(olMailItem)
    Set strAddress = myrs![EmailAddress]
    Set strcc = myrs![ccmail]
    Set strAttach = myrs![OLAttachment]
    Set strmsg = myrs![MainText]
    Set strsubject = myrs![OlSubject]

    'set the outlook values'
    Set objoutlookrecip = .Recipients.Add(strAddress)
    objoutlookrecip.Type = olTo
    Set objoutlookrecip = .Recipients.Add(strcc)
    objoutlookrecip.Type = olCC
    Set objoutlookattach = strAttach
    Set .Subject = strsubject
    Set .Body = strmsg
    Set .Importance = olImportanceHigh
    End With
    Set objoutlookmsg = Nothing
    Set objectoutlook = Nothing

    End Sub

  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    on a quick look I'm guessing that straddress is a string variable, not an object, in which case you can't set. You don't need to assign it to another variable if you are not doing any processing on that variable within the same loop.

  3. #3
    Join Date
    Nov 2005
    Thank you, that worked.

Posting Permissions

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