Results 1 to 4 of 4
  1. #1
    cbrsix is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011

    Add picture to my email code

    I have code to send out emails. I am trying to add after the body of the email but then I get an error saying the object doesn't support this property or method. How can I add the image to my code?
    Private Sub CmdEmail_Click()
    On Error GoTo SendEmail_Err
        Dim myOlApp As Object
        Dim myNameSpace As Object
        Dim myFolder As Object
        Dim myItem As Object
        Dim myAttachments, myRecipient As Object
        Dim recipient As String
        Dim file_name As String
        Dim mySubject As Object
        Dim dbs As Object
        Dim rst As Object
        Dim strSQL As String
        Dim SentOnBehalfOfName As String
    If Me.CountEmail > 0 Then
        strSQL = "SendStudentEmail" 'Select the Query where you want your information to be drawn from
        Set dbs = CurrentDb
        Set rst = dbs.OpenRecordset(strSQL)
        While Not rst.EOF
            recipient = recipient & rst!StudentEmail & ";" 'This is the email address that you corresponds to your recipient
            Set myOlApp = CreateObject("Outlook.Application")
            Set myItem = myOlApp.CreateItem(olMailItem)
            Set myAttachments = myItem.Attachments
            Set myRecipient = myItem.Recipients.Add(recipient)
            myItem.SentOnBehalfOfName = "enter email"
            'myItem.BCC = "" 'Enter any other email recipient that you want CC'd for this email
            '"Message Subject String Here"
            myItem.Subject = Me.EmailSubject
            '"Put Message Body Text Here"
            myItem.Body = IIf(IsNull(rst!FirstName), "Dear Former Student", rst!FirstName) & "," & Chr(13) & Chr(10) & Chr(13) & Chr(10) & Me.EmailBody & Chr(13) & Chr(10) & Chr(13) & Chr(10) & "If you would like to unsubscribe to this email list, please email us at with UNSUBSCRIBE in the Subject." & Chr(13) & Chr(10) & Me.Image16 
        'DoCmd.Close acForm, "SendEmail" 'Closes the form
        'DoCmd.OpenForm "EmailConfirmation" 'Opens Email Confirmation Form
        Set myRecipient = Nothing
        Set myAttachments = Nothing
        Set myItem = Nothing
        Set myOlApp = Nothing
        Set rst = Nothing
        response = MsgBox("There are no recipients to send to.", vbOKOnly)
    End If
        Exit Sub
        MsgBox Err.Description
        Resume SendEmail_Exit
    End Sub

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    The Great Land
    I think you will have to first save the image from the table as an external document. Then try:

    myItem.HTMLBody = "your text here" & "< img src='c:\folder\" & strfilename & ".png'>"

    Use whatever image extension applies.
    How to attach file: To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    cbrsix is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Thanks, that worked but now I am wondering if I can have that image be clickable and lead to an external site (ie the company facebook page, etc)

  4. #4
    cbrsix is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    I got it to work with the following code.

    "<a href=''><img src='C:\Users\John Doe\Desktop\Facebook Logo" & strfilename & ".jpg'></a>"

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 10
    Last Post: 12-15-2012, 01:01 PM
  2. Send Email with Attachment VBA Code
    By kevins in forum Programming
    Replies: 2
    Last Post: 10-03-2012, 01:21 PM
  3. Add email to this piece of code
    By MelonFuel in forum Reports
    Replies: 1
    Last Post: 07-04-2012, 01:34 PM
  4. smtp email code
    By alyon in forum Access
    Replies: 2
    Last Post: 05-15-2012, 07:42 AM
  5. NO minimize button in Email Code
    By taimysho0 in forum Programming
    Replies: 1
    Last Post: 02-03-2012, 08:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Other Forums: Microsoft Office Forums - Senior Forums