• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Qs abt macro to send email from outlook with 2 pictures

lwrgl

New Member
Dears,

I'm trying to send a email from excel macro. And I got stopped by a small step, please help! Explanations below. Thank you so much!!!~
Basically I need to send a email with a 4 rows table. 1st & 3rd rows are contents, 2nd & 4th row is where I want to paste the picture from excel range!!~

My codes are below:

Code:
Sub abc()

Dim myolapp As Object
Dim myitem As Object

Set myolapp = CreateObject("Outlook.Application")
myolapp.Session.Logon

'create email from a template where has a table inside.
Set myitem = myolapp.CreateItemFromTemplate("C:\Users\abc\AppData\Roaming\Microsoft\Templates\test.oft")

With ActiveSheet
Set rngSubject = .Range("Q3")
Set rngBody = .Range(.Range("B2"), .Range("L13")) 'This is the first part I want to copy and paste into my email table
End With
rngBody.Copy

myitem.Subject = rngSubject
myitem.Display

SendKeys "{DOWN}{DOWN}{DOWN}%HVS{UP}~", True 'This will copy my 1st part to email as picture

Set myolapp = Nothing
Set myitem = Nothing
Set rngBody = Nothing


'Now I want to go back to excel to copy the second part, and change to email window to paste in 2nd table as picture
Windows("test.xlsb").Activate
Range("B16:L27").Select
Selection.Copy
Windows(rngSubject & " - Message(HTML).oft").Activate   'But this step failed. also the email copied the 2nd part and pasted in email in my 1st part.
SendKeys "{DOWN}{DOWN}{DOWN}%HVS{UP}~", True

End Sub
 
Back
Top