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

Setup email with attachments.

P: n/a
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

' 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("Outlook.Application")
Set oMail = oLook.createitem(0)
With oMail
.to = "so*****@email.com"
.body = "Attached is a PDF file for your viewing"
.Subject = "Job Item"
.Attachments.Add ("C:\Documents and
Settings\ron_m\Desktop\rptJobItemStat.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
Share this Question
Share on Google+
5 Replies


P: n/a
"paii, Ron" <pa**@packairinc.com> wrote in message
news:vq************@corp.supernews.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.OpenReport "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("Outlook.Application")
Set oMail = oLook.createitem(0)
With oMail
.to = "so*****@email.com"
.body = "Attached is a PDF file for your viewing"
.Subject = "Job Item"
.Attachments.Add ("C:\Documents and
Settings\ron_m\Desktop\rptJobItemStat.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

P: n/a
Thank you Fletcher, that is just what I needed.

"Fletcher Arnold" <fl****@home.com> wrote in message
news:bo**********@titan.btinternet.com...
"paii, Ron" <pa**@packairinc.com> wrote in message
news:vq************@corp.supernews.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.OpenReport "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("Outlook.Application")
Set oMail = oLook.createitem(0)
With oMail
.to = "so*****@email.com"
.body = "Attached is a PDF file for your viewing"
.Subject = "Job Item"
.Attachments.Add ("C:\Documents and
Settings\ron_m\Desktop\rptJobItemStat.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

P: n/a
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_emailAttach(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_emailAttach

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

Set oLook = CreateObject("Outlook.Application")
Set oMail = oLook.createitem(0)
With oMail
.To = stSendTo
.Body = stBody
.Subject = stSubject

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

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

End With

Set oMail = Nothing
Set oLook = Nothing
Pai1_emailAttach = True
Exit Function

errPai1_emailAttach:

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_emailAttach = False

End Function

"Fletcher Arnold" <fl****@home.com> wrote in message
news:bo**********@titan.btinternet.com...
"paii, Ron" <pa**@packairinc.com> wrote in message
news:vq************@corp.supernews.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.OpenReport "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("Outlook.Application")
Set oMail = oLook.createitem(0)
With oMail
.to = "so*****@email.com"
.body = "Attached is a PDF file for your viewing"
.Subject = "Job Item"
.Attachments.Add ("C:\Documents and
Settings\ron_m\Desktop\rptJobItemStat.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

P: n/a
"paii, Ron" <pa**@packairinc.com> wrote in message news:<vq************@corp.supernews.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_emailAttach(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_emailAttach

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

Set oLook = CreateObject("Outlook.Application")
Set oMail = oLook.createitem(0)
With oMail
.To = stSendTo
.Body = stBody
.Subject = stSubject

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

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

End With

Set oMail = Nothing
Set oLook = Nothing
Pai1_emailAttach = True
Exit Function

errPai1_emailAttach:

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_emailAttach = False

End Function

"Fletcher Arnold" <fl****@home.com> wrote in message
news:bo**********@titan.btinternet.com...
"paii, Ron" <pa**@packairinc.com> wrote in message
news:vq************@corp.supernews.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.OpenReport "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("Outlook.Application")
Set oMail = oLook.createitem(0)
With oMail
.to = "so*****@email.com"
.body = "Attached is a PDF file for your viewing"
.Subject = "Job Item"
.Attachments.Add ("C:\Documents and
Settings\ron_m\Desktop\rptJobItemStat.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

P: n/a
"paii, Ron" <pa**@packairinc.com> wrote in message news:<vq************@corp.supernews.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_emailAttach(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_emailAttach

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

Set oLook = CreateObject("Outlook.Application")
Set oMail = oLook.createitem(0)
With oMail
.To = stSendTo
.Body = stBody
.Subject = stSubject

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

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

End With

Set oMail = Nothing
Set oLook = Nothing
Pai1_emailAttach = True
Exit Function

errPai1_emailAttach:

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_emailAttach = False

End Function

"Fletcher Arnold" <fl****@home.com> wrote in message
news:bo**********@titan.btinternet.com...
"paii, Ron" <pa**@packairinc.com> wrote in message
news:vq************@corp.supernews.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.OpenReport "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("Outlook.Application")
Set oMail = oLook.createitem(0)
With oMail
.to = "so*****@email.com"
.body = "Attached is a PDF file for your viewing"
.Subject = "Job Item"
.Attachments.Add ("C:\Documents and
Settings\ron_m\Desktop\rptJobItemStat.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 discussion thread is closed

Replies have been disabled for this discussion.