Repeating attachments using MailEnvelope 2010

Rick Jacobsen

New Member
Joined
Nov 26, 2013
Messages
1
This is my first post and I'm at a loss on this. I'm using Excel 2010 from which I email regularly and to different people changes in the active sheet. I send both the sheet in the body of the mail as well as in a pdf attachment. Everything works fine with my code with the exception that it repeats the attachments. For instance, I can send the first person an email and it will contain one attachment that matches the body of the email. The next person I send one to will get the correct body in the mail but the attachments will contain both the newer pdf and the older pdf. The pdf attachments continue to stack indefinitely. I need a way to clear those attachments prior to sending the next email. Anyone's help with this is GREATLY appreciated!

Sub Button1_Click()




Dim strPath As String, strFName As String, strFName1 As String, rng As Range
Dim OutApp As Object, OutMail As Object


strPath = Environ$("temp") & "\"

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

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
strPath & strFName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False



ActiveWorkbook.EnvelopeVisible = True

With ActiveSheet.MailEnvelope
.Introduction = "Thank you for your quote request. These fees are based on information provided by you. Should this information change the fees reflected herein will be adjusted accordingly." & Chr(13) & Chr(13) & ActiveSheet.Range("AM21") & Chr(13)
.Item.To = "subjectEmail"
.Item.CC = "myemail"
.Item.Subject = "Your Title Quote for" & " " & ActiveSheet.Range("W7")
.Item.Attachments.Add strPath & strFName
.Item.send

End With

Set OutApp = Nothing
Set OutMail = Nothing
Kill strPath & strFName

ActiveSheet.Range("AM21:AW33").ClearContents

End Sub
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,223,237
Messages
6,170,930
Members
452,367
Latest member
TePunaBloke

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