Add attachment olny where are showed on my query.

L

ldiaz

I have this code to send attachments, but it does not work how I want.

I want to send only these attachments where are showed on my query named:
qry_Broker and what is on this field named: Attachment_Document

I want to replaced this from the code..
olattach.Add "C:\Broker System-R1A\pdfAttachments\Invoice-923.pdf", 1
olattach.Add "C:\Broker System-R1A\pdfAttachments\Invoice-924.pdf", 1
olattach.Add "C:\Broker System-R1A\pdfAttachments\Invoice-925.pdf", 1


how can I do that?
Thanks in advanced..


see code.
===================================
Private Sub SendPdfEmail_Click()
'I got this code on the web
Option Explicit
On Error GoTo Err_SendPdfEmail_Click


Dim olapp As Object
Dim olns As Object
Dim olfolder As Object
Dim olitem As Object
Dim olattach As Object

Set olapp = CreateObject("Outlook.Application")
Set olns = olapp.GetNamespace("MAPI")
Set olfolder = olns.getdefaultfolder(6)
Set olitem = olapp.createitem(0)
Set olattach = olitem.attachments

olitem.To = "(e-mail address removed)"
olitem.CC = "(e-mail address removed)"
olitem.Subject = "Receving documents"
olitem.body = "See pdf files for PO information" & Chr(13) & Chr(10)

olattach.Add "C:\Broker System-R1A\pdfAttachments\Invoice-923.pdf", 1
olattach.Add "C:\Broker System-R1A\pdfAttachments\Invoice-924.pdf", 1
olattach.Add "C:\Broker System-R1A\pdfAttachments\Invoice-925.pdf", 1

olitem.display

olitem.send

Set olitem = Nothing
Set rs = Nothing
Set db = Nothing
Set olfolder = Nothing
Set olns = Nothing
Set olapp = Nothing
Exit_SendPdfEmail_Click:
Exit Sub

Err_SendPdfEmail_Click:
MsgBox Err.Description
Resume Exit_SendPdfEmail_Click

End Sub
===================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top