Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email with Attachment

Status
Not open for further replies.

TJVFree

Technical User
Nov 22, 2010
236
US
Hello,

I have a report titled “Monthly ABC Report”

I use the following code to send out the email.
How do I attached the “Monthly ABC Report” to my code below so that it will attach when I send out this email and change it to a PDF?

Code:
Option Compare Database

Sub Mail_Outlook_With_Signature_Html_1()
' Working in Office 2000-2013
    Dim OutApp As Object
    Dim OutMail As Object
    Dim strbody As String

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    strbody = "Please find attached last month's Regions Monthly Report along with #ACCNTS and #GUARS.<br>" & _
              "<br><br>" & _
              "Regions Monthly Presumptive #ACCNTS Export.<br>" & _
              "Regions Monthly Presumptive #GUARS Export.<br>" & _
              "<br><br>" & _
              "Thank you<br>"

On Error Resume Next
 
         

    With OutMail
        .Display
        .To = "
        .CC = "
        .BCC = ""
        .Subject = "Regions Monthly Report"
        .HTMLBody = strbody & "<br>" & .HTMLBody
        .Send
      
    End With

    On Error GoTo 0
    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub


TCB
 
Is the report pdf already on disk or do you need to generate it as well?

John
 
Code:
.Attachments.Add (sFullPathToFile)

But as John states, this will only work if there is a physical file located on the filesystem.

also what are you trying to achieve with this?
Code:
.HTMLBody = strbody & "<br>" & .HTMLBody


"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music
 
Code:
.HTMLBody = strbody & "<br>" & .HTMLBody
this is where I put my name and title

TCB
 
what I mean was you are concatenating the value of .HTMLBody with your string, when from your code snippet, it doesn't equal anything?

You also don't need to blank BCC / CC

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top