Copy & Paste image from a folder to an outlook mail

bluej

New Member
Joined
May 23, 2012
Messages
28
Hi All,

I am new to Macro, please help me out with the below issue:

I need a macro which will copy an image from a folder location and paste it into a mail (outlook).
I dont want the image to be added as an attachment.

Please let me know if you need any more details.

Thanks in advance.

Regards,
BlueJ
 
What errors are you getting with what code? The code in the link I posted should work if you have the relevant references set and a valid filename.
 
Upvote 0
Maybe you can modify the following code to meet your needs...

**Note: Replace each instance of [ and ] with < and >, respectively***

Code:
[FONT=Courier New][COLOR=darkblue]Option[/COLOR] [COLOR=darkblue]Explicit[/COLOR]
[COLOR=darkblue]Sub[/COLOR] EmbedImage()
    [COLOR=darkblue]Dim[/COLOR] objOutlook [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Object[/COLOR]
    [COLOR=darkblue]Dim[/COLOR] objMailItem [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Object[/COLOR]
    
    [COLOR=darkblue]Set[/COLOR] objOutlook = CreateObject("Outlook.Application")
    
    [COLOR=darkblue]Set[/COLOR] objMailItem = objOutlook.CreateItem(0)
    
    [COLOR=darkblue]With[/COLOR] objMailItem
        .To = "[EMAIL="johnsmith@gmail.com"]johnsmith@gmail.com[/EMAIL]"
        .Subject = "Misc..."
        .Attachments.Add "c:\users\domenic\desktop\sample.jpg" [COLOR=#008000]'change the folder and filename accordingly[/COLOR]
        .HTMLBody = "[p]This is the first paragraph...[/p]" & _
            "[img src=""cid:sample.jpg""]" & _
            "[p]This is the second paragraph...[/p]" & _
            "[p]Thank you![/p]"
        .Display
    [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]With[/COLOR]
    
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Sub[/COLOR]
[/FONT]

Note that the above code displays the email, instead of sending it. To send the email, replace...

Code:
.Display

with

Code:
.Send
 
Last edited:
Upvote 0
Hi,

The below code will add it as an attachment. But i need the picture to be pasted in the body of the mail.
Can you please help me out??

Thanks in advance!

Regards,
BlueJ
Maybe you can modify the following code to meet your needs...

**Note: Replace each instance of [ and ] with < and >, respectively***

Code:
[FONT=Courier New][COLOR=darkblue]Option[/COLOR] [COLOR=darkblue]Explicit[/COLOR]
[COLOR=darkblue]Sub[/COLOR] EmbedImage()
    [COLOR=darkblue]Dim[/COLOR] objOutlook [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Object[/COLOR]
    [COLOR=darkblue]Dim[/COLOR] objMailItem [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Object[/COLOR]
    
    [COLOR=darkblue]Set[/COLOR] objOutlook = CreateObject("Outlook.Application")
    
    [COLOR=darkblue]Set[/COLOR] objMailItem = objOutlook.CreateItem(0)
    
    [COLOR=darkblue]With[/COLOR] objMailItem
        .To = "[EMAIL="johnsmith@gmail.com"]johnsmith@gmail.com[/EMAIL]"
        .Subject = "Misc..."
        .Attachments.Add "c:\users\domenic\desktop\sample.jpg" [COLOR=#008000]'change the folder and filename accordingly[/COLOR]
        .HTMLBody = "[p]This is the first paragraph...[/p]" & _
            "[img src=""cid:sample.jpg""]" & _
            "[p]This is the second paragraph...[/p]" & _
            "[p]Thank you![/p]"
        .Display
    [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]With[/COLOR]
    
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Sub[/COLOR]
[/FONT]

Note that the above code displays the email, instead of sending it. To send the email, replace...

Code:
.Display

with

Code:
.Send
 
Upvote 0
Hi,

The below code will add it as an attachment. But i need the picture to be pasted in the body of the mail.
Can you please help me out??

Thanks in advance!

Regards,
BlueJ

Actually, the code does indeed embed the picture within the body of the email. However, it does require the picture to be attached to the email as well. Have you tried it?

Don't forget to replace each instance of [ and ] with < and >, respectively.
 
Upvote 0
Hi,

I have tried it....it sends the picture(image) as an attachment..it doesn insert the image in the body part of the email.

Any help on these lines wud be greatly appreciated.

Thanks in advance..

Regards,
BlueJ

Actually, the code does indeed embed the picture within the body of the email. However, it does require the picture to be attached to the email as well. Have you tried it?

Don't forget to replace each instance of [ and ] with < and >, respectively.
 
Upvote 0

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