Hello All,
I am trying to attach a excel file to email. I have the file being exported to a location then I would like for the email to attach but I keep getting runtime saying that it has been moved or deleted....and the file is there...
Do I need to put a pause in or something to give time to save?
Any Ideas?
I am trying to attach a excel file to email. I have the file being exported to a location then I would like for the email to attach but I keep getting runtime saying that it has been moved or deleted....and the file is there...
Do I need to put a pause in or something to give time to save?
Any Ideas?
Code:
DoCmd.SetWarnings False
Dim FilNam As String
Dim Seeit As String
Dim iTemp As Integer
FilNam = "\\blah blah blah"
DoCmd.OpenQuery "la la report", acViewNormal, acEdit
DoCmd.OutputTo acOutputTable, "la la report", "Excel97-Excel2003Workbook(*.xls)", FilNam, False, "", , acExportQualityPrint
'Ignore errors to allow for error evaluation
On Error Resume Next
iTemp = GetAttr(FilNam)
'Check if error exists and set response appropriately
Select Case Err.Number
Case Is = 0
FileOrDirExists = True
Case Else
FileOrDirExists = False
End Select
'Resume error checking
On Error GoTo 0
If FileOrDirExists Then
Dim outl As Outlook.Application
Set outl = New Outlook.Application
Dim mi As Outlook.MailItem
Set mi = outl.CreateItem(olMailItem)
mi.HTMLBody = "<p>Hello,</p>" & "<p>Give me some chicken"
mi.Subject = "Ribs and Chicken report"
mi.To = "greezychick@blast.com"
mi.Send
mi.Attachments.Add ("The location where the file is at...lol")
Set mi = Nothing
Set outl = Nothing
Application.Quit
Else
Dim outll As Outlook.Application
Set outll = New Outlook.Application
Dim mi1 As Outlook.MailItem
Set mi1 = outl.CreateItem(olMailItem)
mi1.HTMLBody = "Hello"
mi1.Subject = "Tabot sauce"
mi1.To = "greezychick@blast.com"
mi1.Send
Set mi1 = Nothing
Set outll = Nothing
Application.Quit
End If
Proc_702_Auto_Qry_Err:
MsgBox Error$