Lostchrono
New Member
- Joined
- Jun 30, 2014
- Messages
- 3
Hello,
I have the code to auto generate an email using vba. I need to be able to auto generate this email and paste a copy of an image from one of my sheets into the body. Basically it is a Certificate of recognition. I need it to be able to print out, which I have the code for, and email the person the certificate as well.
I have been googling this answer, as well as testing my own thougts, for over a day now and have found several macros for copy and pasting charts and cells but not one for a picture within a sheet. I have tried a Copy and Paste fuction and CopyPicture function and still can't figure it out. Any help would be beneficial. Below you will find the code that I have thus far as well as the CopyPicture variable that I tried to set up but failed. Thank you!
I have the code to auto generate an email using vba. I need to be able to auto generate this email and paste a copy of an image from one of my sheets into the body. Basically it is a Certificate of recognition. I need it to be able to print out, which I have the code for, and email the person the certificate as well.
I have been googling this answer, as well as testing my own thougts, for over a day now and have found several macros for copy and pasting charts and cells but not one for a picture within a sheet. I have tried a Copy and Paste fuction and CopyPicture function and still can't figure it out. Any help would be beneficial. Below you will find the code that I have thus far as well as the CopyPicture variable that I tried to set up but failed. Thank you!
Code:
Sub MailOutlook()
Call InsertTextName
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "Congratulations " & Worksheets("Kudos").AgentNameType.Text & "!" & vbNewLine _
& "You have been awarded a Certificate of Recognition. Keep up the great work!" _
& Worksheets("Certificate").Shapes("CertAll").CopyPicture
On Error Resume Next
With OutMail
.To = "MegaManX@AbelCity.org"
.CC = ""
.BCC = ""
.Subject = "Congratulations to " & Worksheets("Kudos").AgentNameType.Text
.Body = strbody
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
' Sheets("Certificate").PrintOut
End Sub