Emailing PDF quote to client assistance please.

JamesStag

New Member
Joined
Jul 25, 2018
Messages
18
this is what i am working with.
Italic Bold is the part that seems to be the issue so far :)

Code:
Sub sendexcelfileaspdf()
''clickone tools, Reference, create a referance

Dim outlookapp As Outlook.Application
Dim emitem As Object
Dim recipient As String, Subject As String
Dim message As String, Fname As String

'Message details
recipient = Range("C5") & "Stagarborists@Gmail.com"
Subject = "Stag Arborists"
message = Range("C3") & "" & "inPDF format"
message = message & vbNewLine & vbNewLine & "farhan"
Fname = Range("c27")

'Create the PDF attachment
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:=Fname

'Create Outlook Object
[B][I]Set emitem = outlookapp.CreateItem(olMailItem)[/I][/B]
With emitem
.To -recipient
.Subject = Subject
.Body = message
.Attachment.Add Fname
'display
.send
End With
Set outlookapp = Nothing
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
You don't actually seem to have created an instance of Outlook to work with.

Try adding this after the code that creates the attachment.
Code:
Set outlookapp = CreateObject("Outlook.Application")
 
Upvote 0
Unfortunately a no go.

https://ibb.co/jaVaG8
jaVaG8
 
Upvote 0
I'm totally confused.:)

I was able to run this code without error, and even if I did get an error I would expect it to be the one you describe.

Are you definitely getting that error on the line I suggested in post #2 ?
Code:
Sub sendexcelfileaspdf()
Dim outlookapp As Outlook.Application
Dim emitem As Object
Dim recipient As String, Subject As String
Dim message As String, Fname As String

    'Message details
    recipient = Range("C5") & "Stagarborists@Gmail.com"
    Subject = "Stag Arborists"
    message = Range("C3") & "" & "inPDF format"
    message = message & vbNewLine & vbNewLine & "farhan"
    Fname = Range("c27")

    'Create the PDF attachmenth
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Fname
    Set outlookapp = CreateObject("Outlook.Application")
    'Create Outlook Object
    Set emitem = outlookapp.CreateItem(olMailItem)
    
    With emitem
        .To -recipient
        .Subject = Subject
        .Body = message
        .Attachment.Add Fname
        'display
        .send
    End With
    
    Set outlookapp = Nothing
    
End Sub
Of course it didn't do exactly what you want to do but that's because I don't have the same data/setup as you have.
 
Last edited:
Upvote 0
yes its not working coming up with errors. This is what i have come up with now and it works to a degree. I am having trouble getting the .Item.Body = Range("C3").Value to work.

Sub Send_Range()

Dim strPath As String, strFName As String


'Create the PDF
Worksheets("Quote").ExportAsFixedFormat Type:=xlTypePDF, filename:=PdfFile, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False


'Create PDF of active sheet only
strPath = Environ$("temp") & "" 'Or any other path, but include trailing ""

strFName = ActiveWorkbook.Name
strFName = Left(strFName, InStrRev(strFName, ".") - 1) & "_" & ActiveSheet.Name & ".pdf"

Worksheets("Quote").ExportAsFixedFormat Type:=xlTypePDF, filename:= _
strPath & strFName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False

' Select the range of cells on the active worksheet.


' Show the envelope on the ActiveWorkbook.
ActiveWorkbook.EnvelopeVisible = True

' Set the optional introduction field thats adds
' some header text to the email body. It also sets
' the To and Subject lines. Finally the message
' is sent.
On Error Resume Next
With ActiveSheet.MailEnvelope
.Introduction = "This is a sample worksheet."
.Item.To = Range("C8").Value
.Item.Subject = "Stag Arborists"
.Item.Body = Range("C3").Value
.Item.Attachments.Add strPath & strFName
.Item.send
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,099
Messages
6,170,114
Members
452,302
Latest member
TaMere

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top