Results 1 to 3 of 3
  1. #1
    MAAYA is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Nov 2017
    Posts
    2

    Attachments.Add

    Hello,

    I want to send an email with attachment, The files are within the Database (filed data type attachment).
    I get error and I am not fully understand how to get the file to the email message.
    What am I not doing right?
    the table name ComplainTbl and the field called ComplainFileFld

    code :
    Private Sub Command31_Click()
    Dim oApp As New Outlook.Application
    Dim oemail As Outlook.MailItem
    Set oemail = oApp.CreateItem(olMailItem)
    With oemail
    .To = "try@gmail.com "
    .CC = ""
    .Subject = " test "
    .HTMLBody = "<BODY DIR=RTL STYLE='font-family:Arial ;'>" & _
    " Try <br>"


    .Attachments.Add Me.ComplainFilesFld.FileData, Me.ComplainFilesFld.FileType, Me.ComplainFilesFld.FileName
    .Display
    End With




    End Sub

    Its my first time with adding file to emails.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    you did not show us the error or where the error occured.
    but
    did you add the OUTLOOK REFERENCE CHECKED IN VBE; ctl-G, menu,tools, references, , Microsoft Outlook XX Object library?

    attach 1 file at a time
    .Attachments.Add pvFile, olByValue, 1
    .Attachments.Add pvFile2, olByValue, 1

  3. #3
    MAAYA is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Nov 2017
    Posts
    2
    Quote Originally Posted by ranman256 View Post
    you did not show us the error or where the error occured.
    but
    did you add the OUTLOOK REFERENCE CHECKED IN VBE; ctl-G, menu,tools, references, , Microsoft Outlook XX Object library?

    attach 1 file at a time
    .Attachments.Add pvFile, olByValue, 1
    .Attachments.Add pvFile2, olByValue, 1
    Thanks for your answer !
    Yes I added the reference, I can send email message with file with a specific path but not file within the DB.
    I get error 13:"Type mismatch" for the line ".Attachments.Add Me.ComplainFilesFld.FileData, Me.ComplainFilesFld.FileType, Me.ComplainFilesFld.FileName"

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

Similar Threads

  1. Replies: 2
    Last Post: 01-29-2014, 03:19 PM
  2. attachments
    By chiefmsb in forum Forms
    Replies: 3
    Last Post: 08-08-2011, 11:25 AM
  3. attachments
    By chiefmsb in forum Forms
    Replies: 0
    Last Post: 07-12-2011, 07:32 AM
  4. attachments
    By chiefmsb in forum Access
    Replies: 0
    Last Post: 07-10-2011, 07:38 PM
  5. attachments
    By chiefmsb in forum Access
    Replies: 0
    Last Post: 07-08-2011, 03:56 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