I am having one HELL of a time with sending pdfs that I generate.
Outlook is not my preferred mail client but I have the wrethced thing
installed so that I can use some late binding technique I discovered via
Google groups.
What happens is the infernal Outlook security warning appears.
Irritating enough when you have dozens of notices going out, but about
every second operation or fairly randomly, when I press "Yes", I get an
outlook message box error that says "The operation failed". When this
error message occurs, sometimes the email and attachment is sent,
sometimes it isn't. More often it seems to be sent.
It's *&^%ing irritating as all hell and extremely frustrating. Any help
is greatly appreciated, here is my code:
I have a main routine which does through a Jet table and pulls the
contact and attachment (1 pdf that is already generated) info and calls
the following function:
Public Function fSendNotification(strTestTo As String, _
strTo As String, strCC As String, _
strBody As String, strAttach As String) As Boolean
'This function is called from frmFeedNotification
'
'strTestTo - if zls, use strTo for the to, if not use strTestTo
'strTo - to, multiple addresses separated by ;
'strCC - cc, multiple addresses separated by ;
'strBody - body
'strAttach - path to attachment
Dim objOutLook As Object 'outlook object
Dim objMail As Object 'email object to be created
On Error GoTo Err_Proc
SysCmd acSysCmdSetStatus, "Sending report to " & strTo
Set objOutLook = CreateObject("Outlook.Application")
Set objMail = objOutLook.createitem(0)
If strTestTo <"" Then
objMail.To = strTestTo
objMail.body = "To be sent to " & strTo & _
vbCrLf & vbCrLf & strBody
Else
objMail.To = strTo
objMail.body = strBody
End If
If strCC <"<None>" Then objMail.cc = strCC
objMail.Subject = "Facilities Management Banner Charges"
objMail.Attachments.Add strAttach
objMail.send
fSendNotification = True
Exit_Proc:
SysCmd acSysCmdClearStatus
Set objMail = Nothing
Set objOutLook = Nothing
Exit Function
Err_Proc:
Select Case Err.Number 'Access error
Case 287
If MsgBox("You cancelled the sending of the email!" & _
vbCrLf & vbCrLf & "Carry on?", vbQuestion + vbOKCancel _
, "An Email Send Was Cancelled!") = vbOK Then
Resume Next
Else
fSendNotification = False
Resume Exit_Proc
End If
Case 429
fSendNotification = False
MsgBox "There is an email related problem. It " & _
"appears you do not have MS Outlook set " & _
"up on this computer."
Case Else
fSendNotification = False
MsgBox "Error " & Err.Number & " " & _
Err.DESCRIPTION, _
vbCritical, "fSendNotification", _
Err.HelpFile, Err.HelpContext
Resume Exit_Proc
End Select
End Function
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Be Careful, Big Bird!" - Ditto "TIM-MAY!!" - Me