473,395 Members | 2,446 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Is There Any Efficient Way To Email Attachments?

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
6 3478
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
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
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
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

"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Paul Schmidt | last post by:
Dear list: I am new to python, and I am trying to figure out the short answer on something. I want to open a POP3 mailbox, read the enclosed mail using the POP3 module, , and then process it...
3
by: LutherRevisited | last post by:
Is there a way I can put a message together without having to download any attachments there may be at the same time. I'm not having any problems dealing with attachments, but the way I'm doing...
5
by: morphex | last post by:
Hi, I have an email that's in the utf-8 encoding, and I'm getting this error message when I try to send it using smtplib: * Module smtplib, line 688, in sendmail * Module smtplib, line 485,...
5
by: paii, Ron | last post by:
How do I setup a email with attachment for preview but require the user to push the SEND button in Outlook. I have the following function but it sends the email without the sender ever seeing it. ...
12
by: s99999999s2003 | last post by:
hi I have a file which is very large eg over 200Mb , and i am going to use python to code a "tail" command to get the last few lines of the file. What is a good algorithm for this type of task...
1
by: mike11d11 | last post by:
If someone could help me, I need to be able to send attachments from my access database that I have created. This database runs queries then generates a report off the queries from underlying...
10
by: OdAwG | last post by:
Hello All, Is it possible to send an email from Access? I found a Microsoft article on how to do this but I keep getting an error "RUNTIME ERROR 438" -- Object doesn't support this property or...
2
by: oyster | last post by:
I find that the existing email moudle is some hard for me to understand, especially the part of how to set the CC, BCC and attach the files. Is there any more easy one like this p-code? import...
1
by: budyerr | last post by:
All, I am trying to build a email submission form using asp.net. I currently have a web form page that will upload to my webhosting server, attach to email then delete the file after sending. ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.