473,748 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Setup email with attachments.

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.OpenRepor t "rptJobItemStat ", acViewNormal

' The following I got from others in this group to send the email with
the attachment

Dim strEmail As String
Dim strMsg As String
Dim oLook As Object
Dim oMail As Object

Set oLook = CreateObject("O utlook.Applicat ion")
Set oMail = oLook.createite m(0)
With oMail
.to = "so*****@email. com"
.body = "Attached is a PDF file for your viewing"
.Subject = "Job Item"
.Attachments.Ad d ("C:\Documen ts and
Settings\ron_m\ Desktop\rptJobI temStat.pdf")

'********* What is the command to preview instead of send *********
.Send

End With

Set oMail = Nothing
Set oLook = Nothing
End Function

Nov 12 '05 #1
5 15934
"paii, Ron" <pa**@packairin c.com> wrote in message
news:vq******** ****@corp.super news.com...
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.OpenRepor t "rptJobItemStat ", acViewNormal

' The following I got from others in this group to send the email with
the attachment

Dim strEmail As String
Dim strMsg As String
Dim oLook As Object
Dim oMail As Object

Set oLook = CreateObject("O utlook.Applicat ion")
Set oMail = oLook.createite m(0)
With oMail
.to = "so*****@email. com"
.body = "Attached is a PDF file for your viewing"
.Subject = "Job Item"
.Attachments.Ad d ("C:\Documen ts and
Settings\ron_m\ Desktop\rptJobI temStat.pdf")

'********* What is the command to preview instead of send *********
.Send

End With

Set oMail = Nothing
Set oLook = Nothing
End Function


Try .Display instead of .Send

Fletcher
Nov 12 '05 #2
Thank you Fletcher, that is just what I needed.

"Fletcher Arnold" <fl****@home.co m> wrote in message
news:bo******** **@titan.btinte rnet.com...
"paii, Ron" <pa**@packairin c.com> wrote in message
news:vq******** ****@corp.super news.com...
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.OpenRepor t "rptJobItemStat ", acViewNormal

' The following I got from others in this group to send the email with the attachment

Dim strEmail As String
Dim strMsg As String
Dim oLook As Object
Dim oMail As Object

Set oLook = CreateObject("O utlook.Applicat ion")
Set oMail = oLook.createite m(0)
With oMail
.to = "so*****@email. com"
.body = "Attached is a PDF file for your viewing"
.Subject = "Job Item"
.Attachments.Ad d ("C:\Documen ts and
Settings\ron_m\ Desktop\rptJobI temStat.pdf")

'********* What is the command to preview instead of send *********
.Send

End With

Set oMail = Nothing
Set oLook = Nothing
End Function


Try .Display instead of .Send

Fletcher

Nov 12 '05 #3
This is the function I came up with. It may need some more error code but it
works.

'---------------------
' Create a email with attachments
' stSendTo Email address
' stBody Body of the message
' stSubject Subject of the message
' astAttach Array of strings listing the path to the attachments, 0
based
' intAcount Number of attachments
' intSend True if the message should be sent without preview

Public Function Pai1_emailAttac h(ByRef stSendTo As String, ByRef stBody As
String, ByRef stSubject As String, astAttach() As String, intAcount As
Integer, intSend As Integer) As Integer

On Error GoTo errPai1_emailAt tach

Dim oLook As Object
Dim oMail As Object
Dim i As Integer

Set oLook = CreateObject("O utlook.Applicat ion")
Set oMail = oLook.createite m(0)
With oMail
.To = stSendTo
.Body = stBody
.Subject = stSubject

If intAcount <> 0 Then
For i = 1 To intAcount
.Attachments.Ad d (astAttach(i - 1))
Next
End If

If intSend = True Then
.Send
Else
.Display
End If

End With

Set oMail = Nothing
Set oLook = Nothing
Pai1_emailAttac h = True
Exit Function

errPai1_emailAt tach:

MsgBox "The following error was noted : " & Err.Description & Chr$(10) &
Chr$(13) & _
"Your email may not have been sent.", vbCritical, "Error"

On Error Resume Next
Set oMail = Nothing
Set oLook = Nothing
Pai1_emailAttac h = False

End Function

"Fletcher Arnold" <fl****@home.co m> wrote in message
news:bo******** **@titan.btinte rnet.com...
"paii, Ron" <pa**@packairin c.com> wrote in message
news:vq******** ****@corp.super news.com...
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.OpenRepor t "rptJobItemStat ", acViewNormal

' The following I got from others in this group to send the email with the attachment

Dim strEmail As String
Dim strMsg As String
Dim oLook As Object
Dim oMail As Object

Set oLook = CreateObject("O utlook.Applicat ion")
Set oMail = oLook.createite m(0)
With oMail
.to = "so*****@email. com"
.body = "Attached is a PDF file for your viewing"
.Subject = "Job Item"
.Attachments.Ad d ("C:\Documen ts and
Settings\ron_m\ Desktop\rptJobI temStat.pdf")

'********* What is the command to preview instead of send *********
.Send

End With

Set oMail = Nothing
Set oLook = Nothing
End Function


Try .Display instead of .Send

Fletcher

Nov 12 '05 #4
"paii, Ron" <pa**@packairin c.com> wrote in message news:<vq******* *****@corp.supe rnews.com>...
This is the function I came up with. It may need some more error code but it
works.

'---------------------
' Create a email with attachments
' stSendTo Email address
' stBody Body of the message
' stSubject Subject of the message
' astAttach Array of strings listing the path to the attachments, 0
based
' intAcount Number of attachments
' intSend True if the message should be sent without preview

Public Function Pai1_emailAttac h(ByRef stSendTo As String, ByRef stBody As
String, ByRef stSubject As String, astAttach() As String, intAcount As
Integer, intSend As Integer) As Integer

On Error GoTo errPai1_emailAt tach

Dim oLook As Object
Dim oMail As Object
Dim i As Integer

Set oLook = CreateObject("O utlook.Applicat ion")
Set oMail = oLook.createite m(0)
With oMail
.To = stSendTo
.Body = stBody
.Subject = stSubject

If intAcount <> 0 Then
For i = 1 To intAcount
.Attachments.Ad d (astAttach(i - 1))
Next
End If

If intSend = True Then
.Send
Else
.Display
End If

End With

Set oMail = Nothing
Set oLook = Nothing
Pai1_emailAttac h = True
Exit Function

errPai1_emailAt tach:

MsgBox "The following error was noted : " & Err.Description & Chr$(10) &
Chr$(13) & _
"Your email may not have been sent.", vbCritical, "Error"

On Error Resume Next
Set oMail = Nothing
Set oLook = Nothing
Pai1_emailAttac h = False

End Function

"Fletcher Arnold" <fl****@home.co m> wrote in message
news:bo******** **@titan.btinte rnet.com...
"paii, Ron" <pa**@packairin c.com> wrote in message
news:vq******** ****@corp.super news.com...
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.OpenRepor t "rptJobItemStat ", acViewNormal

' The following I got from others in this group to send the email with the attachment

Dim strEmail As String
Dim strMsg As String
Dim oLook As Object
Dim oMail As Object

Set oLook = CreateObject("O utlook.Applicat ion")
Set oMail = oLook.createite m(0)
With oMail
.to = "so*****@email. com"
.body = "Attached is a PDF file for your viewing"
.Subject = "Job Item"
.Attachments.Ad d ("C:\Documen ts and
Settings\ron_m\ Desktop\rptJobI temStat.pdf")

'********* What is the command to preview instead of send *********
.Send

End With

Set oMail = Nothing
Set oLook = Nothing
End Function


Try .Display instead of .Send

Fletcher

Hi
I too am trying to get Access 2002 to send emails. I have tried "paii,
Ron"'s code, which works fine, except that it insists on calling Word
with the email set up correctly, but Word then fails to send the
email. Word sends emails OK normally.

I would prefer to use Outlook. Any ideas how to force Outlook to be
used?

Thanks

Tom Blower
Nov 12 '05 #5
"paii, Ron" <pa**@packairin c.com> wrote in message news:<vq******* *****@corp.supe rnews.com>...
This is the function I came up with. It may need some more error code but it
works.

'---------------------
' Create a email with attachments
' stSendTo Email address
' stBody Body of the message
' stSubject Subject of the message
' astAttach Array of strings listing the path to the attachments, 0
based
' intAcount Number of attachments
' intSend True if the message should be sent without preview

Public Function Pai1_emailAttac h(ByRef stSendTo As String, ByRef stBody As
String, ByRef stSubject As String, astAttach() As String, intAcount As
Integer, intSend As Integer) As Integer

On Error GoTo errPai1_emailAt tach

Dim oLook As Object
Dim oMail As Object
Dim i As Integer

Set oLook = CreateObject("O utlook.Applicat ion")
Set oMail = oLook.createite m(0)
With oMail
.To = stSendTo
.Body = stBody
.Subject = stSubject

If intAcount <> 0 Then
For i = 1 To intAcount
.Attachments.Ad d (astAttach(i - 1))
Next
End If

If intSend = True Then
.Send
Else
.Display
End If

End With

Set oMail = Nothing
Set oLook = Nothing
Pai1_emailAttac h = True
Exit Function

errPai1_emailAt tach:

MsgBox "The following error was noted : " & Err.Description & Chr$(10) &
Chr$(13) & _
"Your email may not have been sent.", vbCritical, "Error"

On Error Resume Next
Set oMail = Nothing
Set oLook = Nothing
Pai1_emailAttac h = False

End Function

"Fletcher Arnold" <fl****@home.co m> wrote in message
news:bo******** **@titan.btinte rnet.com...
"paii, Ron" <pa**@packairin c.com> wrote in message
news:vq******** ****@corp.super news.com...
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.OpenRepor t "rptJobItemStat ", acViewNormal

' The following I got from others in this group to send the email with the attachment

Dim strEmail As String
Dim strMsg As String
Dim oLook As Object
Dim oMail As Object

Set oLook = CreateObject("O utlook.Applicat ion")
Set oMail = oLook.createite m(0)
With oMail
.to = "so*****@email. com"
.body = "Attached is a PDF file for your viewing"
.Subject = "Job Item"
.Attachments.Ad d ("C:\Documen ts and
Settings\ron_m\ Desktop\rptJobI temStat.pdf")

'********* What is the command to preview instead of send *********
.Send

End With

Set oMail = Nothing
Set oLook = Nothing
End Function


Try .Display instead of .Send

Fletcher

HI (again)
I have just said the Word fails to send the e-mails. WRONG! I have
been able to retrieve the emails using Outlook, whereas before I was
using Outlook Express, which for some strange reason resolutely
refused to retrieve them.

Perhaps I was too keen to collect.

Safe to say that your code "paii, Ron" works perfectly! Many thanks.

Tom Blower
Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3731
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
3146
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
12729
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
9
11877
by: ibm_97 | last post by:
Hi, Anyone can give me a link which shows how to setup DB2 (v8) replication step by step? Thanks. As a non-DB2 person, I find out IBM DB2 doc is not very helpful at all, espeically compare with Oracle docs. Regards,
4
1940
by: Russell Bungay | last post by:
Hello all, I have written a short function, based on a recipe in the Python Cookbook, that sends an e-mail. The function takes arguments that define who the e-mail is to, from, the subject, the body and an optional list of attachments. The function works also perfectly, bar one slight problem. If you attempt to send an e-mail with just a body and no attachments, the receiving client still thinks that there is an attachment (so far...
1
2903
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
4970
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
2647
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
3876
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
8995
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
8832
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
9558
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9378
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...
1
9331
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8250
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4608
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...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3316
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

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.