Excel Auto Emailing w/copy paste

Seven2010

New Member
Joined
Jan 8, 2010
Messages
9
Found this code in your achieves - works like a charm.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
<o:p></o:p>
2 Questions:<o:p></o:p>
<o:p></o:p>
1. I have a worksheet that I would like to copy and paste into the body of the email as a picture - could vary in row numbers.
Any suggestions?<o:p></o:p>
<o:p></o:p>
2. Rather than running the macro I would like to auto run based on the answer "yes" in a specific cell.<o:p></o:p>
<o:p></o:p>
Not my area of expertise so your help is appreciated. Thanks<o:p></o:p>

Sub Email()
' Email Macro
' Macro by Thomas Urtis

Dim Resp As Integer
Resp = MsgBox(prompt:="Click Yes to review email, No to immediately send, or Cancel.", _
Title:="Email options: Want to review email before sending?", _
Buttons:=3 + 32)

Select Case Resp
'Yes was clicked, user wants to review email first
Case Is = 6
Dim myOutlook As Object
Dim myMailItem As Object
Set otlApp = CreateObject("Outlook.Application")
Set otlNewMail = otlApp.CreateItem(olMailItem)
fName = ActiveWorkbook.Path & "\" & ActiveWorkbook.Name
With otlNewMail
.To = "jane.doe@anywhere.com"
.CC = "jane.doe@anywhere.com"
.Subject = "email from me"
.Body = "Attached is today's Report." & Chr(13) & "Regards," & Chr(13) & "Ben" & Chr(13) & Chr(13)
.Attachments.Add fName
.Display
End With

Set otlNewMail = Nothing
Set otlApp = Nothing
Set otlAttach = Nothing
Set otlMess = Nothing
Set otlNSpace = Nothing

'If no is clicked
Case Is = 7
Dim myOutlok As Object
Dim myMailItm As Object
Set otlApp = CreateObject("Outlook.Application")
Set otlNewMail = otlApp.CreateItem(olMailItem)
fName = ActiveWorkbook.Path & "\" & ActiveWorkbook.Name
With otlNewMail
.To = "jane.doe@anywhere.com"
.CC = "jane.doe@anywhere.com"
.Subject = "email from me"
.Body = "Attached is today's Report." & Chr(13) & "Regards," & Chr(13) & "Ben" & Chr(13) & Chr(13)
.Attachments.Add fName
.Send
End With

Set otlNewMail = Nothing
Set otlApp = Nothing
Set otlAttach = Nothing
Set otlMess = Nothing
Set otlNSpace = Nothing

'If Cancel is clicked
Case Is = 2
MsgBox prompt:="Click OK to return to Report.", _
Title:="EMAIL CANCELLED", _
Buttons:=64
End Select
End Sub
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
OK, thanks for that. Maybe we can simplify. What if we paste as an excel spreadsheet? Does that make it easier? Thanks
 
Upvote 0
I have found a link where you will find the code you need to be able to paste a picture in the body of an email.
The example uses Microsoft Access but it works also for Excel. I have managed to run modified code in Outlook itself and also in Excel VBA, but it is better that you follow the link as it will contain much more useful code - there is also a workbook that you can download.
You will probably have to first save the 'picture' to a file first.
http://www.access-programmers.co.uk/forums/showthread.php?t=145301
 
Upvote 0

Forum statistics

Threads
1,215,787
Messages
6,126,897
Members
449,347
Latest member
Macro_learner

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