J
Jackie L
I am using Bill Mosca's function for Outlook_SendEmail but I am having
difficulty getting multiple attachments to work.
I am creating a .pdf file of a report and then concatenating unlimited files
based on file location string in a field.
My issue is this, when I send just the .pdf as an attachment, it works, when
I send the file strings as text (i.e. "c:\File1.xls",
"c:\File2.xls","c:\File3.xls") typed into the code, it works.
If I declare a string and define it as the file locations, it does not work.
I believe the issue is with the quotation marks but I cannot come up with a
combination that the function will accept. I have also declared a string for
the quotation marks so that there is no problem with double or single
quotations.
I have not worked with arrays but I could populate one with the file
locations if need be.
The following code puts a quotation mark at the beginning and ending of the
strAttachment but I have done it in all combinations. If there are no
attachments besides the PO itself, the code runs.
Dim strMsg As String
Dim BlockCount As Integer
Dim Counter As Integer
Dim RptName As String
Dim SnapshotName As String
Dim OutputPDFName As String
Dim blRet As Boolean
Dim ShowSaveFileDialog As Boolean
Dim StartPDFViewer As Boolean
Dim strSubject As String
Dim strAddress As String
Dim strMessage As String
Dim strAttachments As String
Dim strPOFiles As String
Dim strQuotation As String
strQuotation = Chr$(34)
If Forms!frmPurchaseOrder!Type = "Vendor" Then
RptName = "rptPurchaseOrderVendor"
Else
RptName = "rptPurchaseOrder"
End If
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryPOFiles"
DoCmd.OpenForm "frmPOFiles"
DoCmd.SetWarnings True
strPOFiles = Nz(DMax("Attachments", "tblPOFilesTemp"))
ShowSaveFileDialog = False
StartPDFViewer = False
strMsg = "You are about to send PO to the email address listed."
strSubject = "Purchase Order"
If MsgBox(strMsg, vbOKCancel, "Email PO") = vbOK Then
strAddress = Forms!frmPurchaseOrder!POEmail
strMessage = Me.EmailNote & Chr(13) & Chr(13) & Me.EmpName
OutputPDFName = "S:\Work Order Database\PO Sent\" & Forms! _
frmPurchaseOrder!PONumber & ".pdf"
blRet = ConvertReportToPDF(RptName, vbNullString, _
OutputPDFName, False, True, 0, "", "", 0, 0)
'to add attachments created by frmPOFiles
If DCount("QuoteFile", "tblPOFilesTemp") > 0 Then
strAttachments = strQuotation & OutputPDFName & ", " &
strPOFiles & strQuotation
Else
strAttachments = OutputPDFName
End If
Me.FileTest = strAttachments
MsgBox Outlook_SendEmail(strSubject, strAddress, strMessage,
strAttachments)
DoCmd.SelectObject acForm, "frmPurchaseOrder", True
DoCmd.RunCommand acCmdFormView
MsgBox "Purchase Order sent."
Forms!frmPurchaseOrder!EmailSent = Now()
DoCmd.Close acForm, "frmPurchaseOrderEmail"
Else
Exit Sub
End If
I apologize if this is confusing, I just need what the snytax needs to be
for the attachments.
Thanks,
Jackie
difficulty getting multiple attachments to work.
I am creating a .pdf file of a report and then concatenating unlimited files
based on file location string in a field.
My issue is this, when I send just the .pdf as an attachment, it works, when
I send the file strings as text (i.e. "c:\File1.xls",
"c:\File2.xls","c:\File3.xls") typed into the code, it works.
If I declare a string and define it as the file locations, it does not work.
I believe the issue is with the quotation marks but I cannot come up with a
combination that the function will accept. I have also declared a string for
the quotation marks so that there is no problem with double or single
quotations.
I have not worked with arrays but I could populate one with the file
locations if need be.
The following code puts a quotation mark at the beginning and ending of the
strAttachment but I have done it in all combinations. If there are no
attachments besides the PO itself, the code runs.
Dim strMsg As String
Dim BlockCount As Integer
Dim Counter As Integer
Dim RptName As String
Dim SnapshotName As String
Dim OutputPDFName As String
Dim blRet As Boolean
Dim ShowSaveFileDialog As Boolean
Dim StartPDFViewer As Boolean
Dim strSubject As String
Dim strAddress As String
Dim strMessage As String
Dim strAttachments As String
Dim strPOFiles As String
Dim strQuotation As String
strQuotation = Chr$(34)
If Forms!frmPurchaseOrder!Type = "Vendor" Then
RptName = "rptPurchaseOrderVendor"
Else
RptName = "rptPurchaseOrder"
End If
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryPOFiles"
DoCmd.OpenForm "frmPOFiles"
DoCmd.SetWarnings True
strPOFiles = Nz(DMax("Attachments", "tblPOFilesTemp"))
ShowSaveFileDialog = False
StartPDFViewer = False
strMsg = "You are about to send PO to the email address listed."
strSubject = "Purchase Order"
If MsgBox(strMsg, vbOKCancel, "Email PO") = vbOK Then
strAddress = Forms!frmPurchaseOrder!POEmail
strMessage = Me.EmailNote & Chr(13) & Chr(13) & Me.EmpName
OutputPDFName = "S:\Work Order Database\PO Sent\" & Forms! _
frmPurchaseOrder!PONumber & ".pdf"
blRet = ConvertReportToPDF(RptName, vbNullString, _
OutputPDFName, False, True, 0, "", "", 0, 0)
'to add attachments created by frmPOFiles
If DCount("QuoteFile", "tblPOFilesTemp") > 0 Then
strAttachments = strQuotation & OutputPDFName & ", " &
strPOFiles & strQuotation
Else
strAttachments = OutputPDFName
End If
Me.FileTest = strAttachments
MsgBox Outlook_SendEmail(strSubject, strAddress, strMessage,
strAttachments)
DoCmd.SelectObject acForm, "frmPurchaseOrder", True
DoCmd.RunCommand acCmdFormView
MsgBox "Purchase Order sent."
Forms!frmPurchaseOrder!EmailSent = Now()
DoCmd.Close acForm, "frmPurchaseOrderEmail"
Else
Exit Sub
End If
I apologize if this is confusing, I just need what the snytax needs to be
for the attachments.
Thanks,
Jackie