By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,454 Members | 3,133 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,454 IT Pros & Developers. It's quick & easy.

Is There Any Efficient Way To Email Attachments?

P: n/a
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
May 3 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Tim Marshall wrote:
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
Get the free utility ExpressclickYes to automatically reply to the
Microsoft email warnings. Turn it on before your automated email
process runs and then turn it off after.

Bob
May 3 '07 #2

P: n/a
Tim Marshall <TI****@PurplePandaChasers.Moertheriumwrote:
>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 is your preferred email client?
>What happens is the infernal Outlook security warning appears.
Bob's already given you one answer. There are a few more as well at the Outlook
specific links at the Access Email FAQ at my website.
http://www.granite.ab.ca/access/email/outlook.htm

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
May 3 '07 #3

P: n/a
Tim Marshall wrote:
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.
You might be able to do this using the CDO library if your Windows PC has it installed.
You'll need to know the IP address of your SMTP (outgoing mail) server:
Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).

Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Sample CDO Message"
objMessage.From = """Me"" <me@my.com>"
objMessage.To = "so******@yahoo.com"
objMessage.TextBody = "This is some sample message text.." & vbCRLF & "It was sent using
SMTP authentication."

'==This section provides the configuration information for the remote SMTP server.

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.your.com"

'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic

'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "youruserid"

'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "yourpassword"

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False

'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to
the SMTP server)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

objMessage.Configuration.Fields.Update

'==End remote SMTP server configuration section==
objMessage.AddAttachment "c:\temp\testfile.doc"
objMessage.Send

--
---------------
John Mishefske, Microsoft Access MVP
May 3 '07 #4

P: n/a
On May 2, 5:49 pm, Tim Marshall
<TIM...@PurplePandaChasers.Moertheriumwrote:
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
or use blat (www.blat.net) to send without need a client

May 3 '07 #5

P: n/a

"Tim Marshall" <TI****@PurplePandaChasers.Moertheriumwrote in message
news:f1**********@coranto.ucs.mun.ca...
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
A discussion started on April 24th with the subject "Auto Email PDF" where
John Mishefske posted code to directly send email. I pasted it into a
function, declared the object variable, filled in my email server's address
and set an email, without Outlook complaning.
May 3 '07 #6

P: n/a
paii, Ron wrote:
A discussion started on April 24th with the subject "Auto Email PDF" where
John Mishefske posted code to directly send email. I pasted it into a
function, declared the object variable, filled in my email server's address
and set an email, without Outlook complaning.
Thanks to everyone for replying. I've used Blat in the past on
A97/win98 apps and it worked fine, not sure why I didn't use it in the
first place...

I'm going to look into JOhn's answer on this thread and on the one Ron
referenced as well and ExpressClickYes sounds interesting as well.

What I've found in the meantime is that if my user makes sure she turns
on and logs into her Outlook account, I don't get the Outlook error
messages at all. Still would like to dispense with the silly warnings,
though.

Thanks again to all.
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Be Careful, Big Bird!" - Ditto "TIM-MAY!!" - Me
May 3 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.