473,659 Members | 2,683 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 fSendNotificati on(strTestTo As String, _
strTo As String, strCC As String, _
strBody As String, strAttach As String) As Boolean

'This function is called from frmFeedNotifica tion
'
'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 acSysCmdSetStat us, "Sending report to " & strTo

Set objOutLook = CreateObject("O utlook.Applicat ion")
Set objMail = objOutLook.crea teitem(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.Attachm ents.Add strAttach

objMail.send

fSendNotificati on = True

Exit_Proc:
SysCmd acSysCmdClearSt atus
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
fSendNotificati on = False
Resume Exit_Proc
End If
Case 429
fSendNotificati on = False
MsgBox "There is an email related problem. It " & _
"appears you do not have MS Outlook set " & _
"up on this computer."
Case Else
fSendNotificati on = False
MsgBox "Error " & Err.Number & " " & _
Err.DESCRIPTION , _
vbCritical, "fSendNotificat ion", _
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 3494
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 fSendNotificati on(strTestTo As String, _
strTo As String, strCC As String, _
strBody As String, strAttach As String) As Boolean

'This function is called from frmFeedNotifica tion
'
'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 acSysCmdSetStat us, "Sending report to " & strTo

Set objOutLook = CreateObject("O utlook.Applicat ion")
Set objMail = objOutLook.crea teitem(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.Attachm ents.Add strAttach

objMail.send

fSendNotificati on = True

Exit_Proc:
SysCmd acSysCmdClearSt atus
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
fSendNotificati on = False
Resume Exit_Proc
End If
Case 429
fSendNotificati on = False
MsgBox "There is an email related problem. It " & _
"appears you do not have MS Outlook set " & _
"up on this computer."
Case Else
fSendNotificati on = False
MsgBox "Error " & Err.Number & " " & _
Err.DESCRIPTION , _
vbCritical, "fSendNotificat ion", _
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****@PurpleP andaChasers.Moe rtheriumwrote:
>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 cdoSendUsingPic kup = 1 'Send message using the local SMTP service pickup directory.
Const cdoSendUsingPor t = 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("C DO.Message")
objMessage.Subj ect = "Sample CDO Message"
objMessage.From = """Me"" <me@my.com>"
objMessage.To = "so******@yahoo .com"
objMessage.Text Body = "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.Conf iguration.Field s.Item _
("http://schemas.microso ft.com/cdo/configuration/sendusing") = 2

'Name or IP of Remote SMTP Server
objMessage.Conf iguration.Field s.Item _
("http://schemas.microso ft.com/cdo/configuration/smtpserver") = "mail.your. com"

'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Conf iguration.Field s.Item _
("http://schemas.microso ft.com/cdo/configuration/smtpauthenticat e") = cdoBasic

'Your UserID on the SMTP server
objMessage.Conf iguration.Field s.Item _
("http://schemas.microso ft.com/cdo/configuration/sendusername") = "youruserid "

'Your password on the SMTP server
objMessage.Conf iguration.Field s.Item _
("http://schemas.microso ft.com/cdo/configuration/sendpassword") = "yourpasswo rd"

'Server port (typically 25)
objMessage.Conf iguration.Field s.Item _
("http://schemas.microso ft.com/cdo/configuration/smtpserverport" ) = 25

'Use SSL for the connection (False or True)
objMessage.Conf iguration.Field s.Item _
("http://schemas.microso ft.com/cdo/configuration/smtpusessl") = False

'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to
the SMTP server)
objMessage.Conf iguration.Field s.Item _
("http://schemas.microso ft.com/cdo/configuration/smtpconnectiont imeout") = 60

objMessage.Conf iguration.Field s.Update

'==End remote SMTP server configuration section==
objMessage.AddA ttachment "c:\temp\testfi le.doc"
objMessage.Send

--
---------------
John Mishefske, Microsoft Access MVP
May 3 '07 #4
On May 2, 5:49 pm, Tim Marshall
<TIM...@PurpleP andaChasers.Moe rtheriumwrote:
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 fSendNotificati on(strTestTo As String, _
strTo As String, strCC As String, _
strBody As String, strAttach As String) As Boolean

'This function is called from frmFeedNotifica tion
'
'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 acSysCmdSetStat us, "Sending report to " & strTo

Set objOutLook = CreateObject("O utlook.Applicat ion")
Set objMail = objOutLook.crea teitem(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.Attachm ents.Add strAttach

objMail.send

fSendNotificati on = True

Exit_Proc:
SysCmd acSysCmdClearSt atus
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
fSendNotificati on = False
Resume Exit_Proc
End If
Case 429
fSendNotificati on = False
MsgBox "There is an email related problem. It " & _
"appears you do not have MS Outlook set " & _
"up on this computer."
Case Else
fSendNotificati on = False
MsgBox "Error " & Err.Number & " " & _
Err.DESCRIPTION , _
vbCritical, "fSendNotificat ion", _
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****@PurpleP andaChasers.Moe rtheriumwrote 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 fSendNotificati on(strTestTo As String, _
strTo As String, strCC As String, _
strBody As String, strAttach As String) As Boolean

'This function is called from frmFeedNotifica tion
'
'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 acSysCmdSetStat us, "Sending report to " & strTo

Set objOutLook = CreateObject("O utlook.Applicat ion")
Set objMail = objOutLook.crea teitem(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.Attachm ents.Add strAttach

objMail.send

fSendNotificati on = True

Exit_Proc:
SysCmd acSysCmdClearSt atus
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
fSendNotificati on = False
Resume Exit_Proc
End If
Case 429
fSendNotificati on = False
MsgBox "There is an email related problem. It " & _
"appears you do not have MS Outlook set " & _
"up on this computer."
Case Else
fSendNotificati on = False
MsgBox "Error " & Err.Number & " " & _
Err.DESCRIPTION , _
vbCritical, "fSendNotificat ion", _
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
3728
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 using the email module. Environment Python 2.3.4, Mandrake Linux 9.0 patched up the wazoo...
3
3139
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 things makes me download the complete message first, attachements and all: mail = for j in M.retr(i): mail.append(j.rstrip()) inMail = email.message_from_string('\r\n'.join(mail)) I don't have a real problem per se with this, it's just that I...
5
12677
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, in data * Module smtplib, line 312, in send * Module socket, line 1, in sendall
5
15928
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. Public Function PrintPDFemail2() ' This will create the PDF if the report is setup for it DoCmd.OpenReport "rptJobItemStat", acViewNormal
12
4367
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 in python for very big files? Initially, i thought of reading everything into an array from the file and just get the last few elements (lines) but since it's a very big file, don't think is efficient. thanks
1
2881
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 tables and emails the reports as HTML format in the body, I then need to have this same process go out to my C:\ drive and pick up a couple files and add it to the same email as attachments. If someone could please give me a sample code that would...
10
4963
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 method. Listed below is the article from microsoft How to use a recordset to send Outlook e-mail to multiple recipients in Microsoft Access http://support.microsoft.com/?id=318881
2
2645
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 easyemail smtpserver=easyemail.server('something') smtpserver.login('usr@gmail.com', pwd) newletter=smtpsever.letter(smtpserver) newletter.sendto= newletter.sendcc=
1
3868
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. This works great with one attachment. I am requiring that a file be attach before submitting. Now I am trying to add the ability to add multiple attachments and I am able to create this however, it will error out if all of the attachment is not...
0
8427
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8332
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8627
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2750
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.