How to insert a picture programatically

Status
Not open for further replies.
S

Southern at Heart

Via a custom tool bar button, I want to use vba to insert a picture into the

body of my email (not an attachment). The picture's URL is strURL. Does

anyone know how to do this?
 
S

Sue Mosher [MVP]

The appropriate technique depends on the Outlook version and, in older

versions, whether Word is the email editor. Please always include such

details when you post Outlook questions.

Sue Mosher

"Southern at Heart" <SouthernatHeart> wrote in

message news:40C599CD-8CEC-4C22-8681-A6329772CE3A@microsoft.com...
> Via a custom tool bar button, I want to use vba to insert a picture into
> the
> body of my email (not an attachment). The picture's URL is strURL. Does
> anyone know how to do this?
 
S

Southern at Heart

Oh yes, sorry,

I have Outlook 2003, and I use Word 2003 as my email editor...

many thanks,

"Sue Mosher [MVP]" wrote:


> The appropriate technique depends on the Outlook version and, in older
> versions, whether Word is the email editor. Please always include such
> details when you post Outlook questions.
> > Sue Mosher
> > >

> "Southern at Heart" <SouthernatHeart> wrote in
> message news:40C599CD-8CEC-4C22-8681-A6329772CE3A@microsoft.com...
> > Via a custom tool bar button, I want to use vba to insert a picture into
> > the
> > body of my email (not an attachment). The picture's URL is strURL. Does
> > anyone know how to do this?


> .
>
 
S

Sue Mosher [MVP]

In that case, you can return a Word.Document using Inspector.WordEditor and

then use Word methods to perform the insertion, something like this, where

objMsg is the message you want to modify:

strFile = "C:\Pictures\logo.gif"

Set objInsp = objMsg.GetInspector

Set objDoc = objInsp.WordEditor

Set objSel = objDoc.Windows(1).Selection

If objMsg.BodyFormat <> olFormatPlain Then

Set objShape = objSel.InlineShapes.AddPicture _

(strFile, False, True)

objDoc.Hyperlinks.Add objShape.Range, strURL

End If

This technique would also work in Outlook 2007, which always uses Word as

the email editor.

Sue Mosher

"Southern at Heart" <SouthernatHeart> wrote in

message news:F957F25C-A831-4BDE-A415-36F86BB1C3CC@microsoft.com...

> I have Outlook 2003, and I use Word 2003 as my email editor...
>
> > > Via a custom tool bar button, I want to use vba to insert a picture
> > > into
> > > the
> > > body of my email (not an attachment). The picture's URL is strURL.
> > > Does
> > > anyone know how to do this?
 
S

Southern at Heart

I don't understand everything I know about this!

In Outlook 2003, using Word 2003 as my editor, I click on the new message

button to start a new email. It won't let me 'customize' the toolbar, but I

see custom buttons up there that I made in Word. So I cut my code out of

'ThisOutlookSession' and opened up Word and pasted it in for Normal.dot, then

I added a button on Word's toolbar to run it. I close Word, go back to

Outlook, click New Email, and now I see my custom button! Hurray, I'm

getting somewhere. But now, it doesn't work. It seems like I am missing the

part that defines objMsg? How do I do this?

Also, I don't understand the reference of 'strFile = "C:\Pictures\logo.gif"

because the picture I'm trying to paste is located on the web at strURL

Thanks for your patience with SouthernAtHeart!

Here's my code:

Sub InsertPicture()

strFile = "C:\Pictures\logo.gif"

Set objInsp = objMsg.GetInspector

Set objDoc = objInsp.WordEditor

Set objSel = objDoc.Windows(1).Selection

If objMsg.BodyFormat <> olFormatPlain Then

Set objShape = objSel.InlineShapes.AddPicture _

(strFile, False, True)

objDoc.Hyperlinks.Add objShape.Range, strURL

End If
 
S

Sue Mosher [MVP]

I'm sorry, but I may have misinterpreted what you wanted to do. I thought

that you wanted to insert an image you already had and use it to link to

some location with strURL. But now it seems that you want to insert an image

that only exists on the Internet. Is that correct? In general, this is not a

good practice in email messages, because Outlook and many other mail

programs by default will not load content from the Internet, for security

and privacy reasons. Best practice is to embed the image into the message

from a file that already exists locally, as shown in the code I posted.

If you insist on using a web-based image, then you would need to modify the

HTMLBody property of the message to insert an <img> tag at the desired

location, just the same as you would with a web page. The code sample at

http://www.outlookcode.com/codedetail.aspx?id=1358 shows how to insert an

HTML content string into the current cursor position, but I don't know

whether it will work if Word is the email editor. You'll have to try it and

see.

Sue Mosher

"Southern at Heart" <SouthernatHeart> wrote in

message news:14C16A87-4E35-4102-9BFD-F712FEB6883F@microsoft.com...
> I don't understand everything I know about this!

> In Outlook 2003, using Word 2003 as my editor, I click on the new message
> button to start a new email. It won't let me 'customize' the toolbar, but
> I
> see custom buttons up there that I made in Word. So I cut my code out of
> 'ThisOutlookSession' and opened up Word and pasted it in for Normal.dot,
> then
> I added a button on Word's toolbar to run it. I close Word, go back to
> Outlook, click New Email, and now I see my custom button! Hurray, I'm
> getting somewhere. But now, it doesn't work. It seems like I am missing
> the
> part that defines objMsg? How do I do this?
> Also, I don't understand the reference of 'strFile =
> "C:\Pictures\logo.gif"
> because the picture I'm trying to paste is located on the web at strURL
> Thanks for your patience with SouthernAtHeart!

> Here's my code:
> Sub InsertPicture()

> strFile = "C:\Pictures\logo.gif"
> Set objInsp = objMsg.GetInspector
> Set objDoc = objInsp.WordEditor
> Set objSel = objDoc.Windows(1).Selection
> If objMsg.BodyFormat <> olFormatPlain Then
> Set objShape = objSel.InlineShapes.AddPicture _
> (strFile, False, True)
> objDoc.Hyperlinks.Add objShape.Range, strURL
> End If
>


"Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message

news:e1mYnQFmKHA.1652@TK2MSFTNGP05.phx.gbl...
> In that case, you can return a Word.Document using Inspector.WordEditor
> and
> then use Word methods to perform the insertion, something like this, where
> objMsg is the message you want to modify:

> strFile = "C:\Pictures\logo.gif"
> Set objInsp = objMsg.GetInspector
> Set objDoc = objInsp.WordEditor
> Set objSel = objDoc.Windows(1).Selection
> If objMsg.BodyFormat <> olFormatPlain Then
> Set objShape = objSel.InlineShapes.AddPicture _
> (strFile, False, True)
> objDoc.Hyperlinks.Add objShape.Range, strURL
> End If

> This technique would also work in Outlook 2007, which always uses Word as
> the email editor.

> "Southern at Heart" <SouthernatHeart> wrote in
> message news:F957F25C-A831-4BDE-A415-36F86BB1C3CC@microsoft.com...
>

>> I have Outlook 2003, and I use Word 2003 as my email editor...
> >
> >> > Via a custom tool bar button, I want to use vba to insert a picture
> >> > into
> >> > the
> >> > body of my email (not an attachment). The picture's URL is strURL.
> >> > Does
> >> > anyone know how to do this?
 
S

Southern at Heart

Hi,

Let me explain more simply what I want to do:

I have strURL that is the location of a picture, say for example:

strURL = http://www.google.com/intl/en_ALL/images/logo.gif

> ...I just want to 'paste' the image in the email body as a picture. I don't

want the email to contain a link to the web based picture, but I want to

simply paste the picture just as if it were a picture on my PC that I wanted

to paste into the email. I don't want the picture to be an attachment, just

pasted in the body of the email.

Thank much! Sorry I'm not able to explain myself very well sometimes.
 
S

Sue Mosher [MVP]

I'm confused. Do you have only the URL for the picture? Or do you have the

picture on the clipboard, ready to paste?

Sue Mosher

"Southern at Heart" <SouthernatHeart> wrote in

message news:56CFCA24-FC2D-48BB-91EB-CCE170290AD3@microsoft.com...
> Hi,
> Let me explain more simply what I want to do:
> I have strURL that is the location of a picture, say for example:
> strURL = http://www.google.com/intl/en_ALL/images/logo.gif

> ...I just want to 'paste' the image in the email body as a picture. I
> don't
> want the email to contain a link to the web based picture, but I want to
> simply paste the picture just as if it were a picture on my PC that I
> wanted
> to paste into the email. I don't want the picture to be an attachment,
> just
> pasted in the body of the email.
> Thank much! Sorry I'm not able to explain myself very well sometimes.
>


"Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message

news:eBsuNwRmKHA.2780@TK2MSFTNGP05.phx.gbl...
> I'm sorry, but I may have misinterpreted what you wanted to do. I thought
> that you wanted to insert an image you already had and use it to link to
> some location with strURL. But now it seems that you want to insert an
> image
> that only exists on the Internet. Is that correct? In general, this is not
> a
> good practice in email messages, because Outlook and many other mail
> programs by default will not load content from the Internet, for security
> and privacy reasons. Best practice is to embed the image into the message
> from a file that already exists locally, as shown in the code I posted.

> If you insist on using a web-based image, then you would need to modify
> the
> HTMLBody property of the message to insert an <img> tag at the desired
> location, just the same as you would with a web page. The code sample at
> http://www.outlookcode.com/codedetail.aspx?id=1358 shows how to insert an
> HTML content string into the current cursor position, but I don't know
> whether it will work if Word is the email editor. You'll have to try it
> and
> see.

> "Southern at Heart" <SouthernatHeart> wrote in
> message news:14C16A87-4E35-4102-9BFD-F712FEB6883F@microsoft.com...
> >I don't understand everything I know about this!
>

>> In Outlook 2003, using Word 2003 as my editor, I click on the new message
> > button to start a new email. It won't let me 'customize' the toolbar,
> > but
> > I
> > see custom buttons up there that I made in Word. So I cut my code out of
> > 'ThisOutlookSession' and opened up Word and pasted it in for Normal.dot,
> > then
> > I added a button on Word's toolbar to run it. I close Word, go back to
> > Outlook, click New Email, and now I see my custom button! Hurray, I'm
> > getting somewhere. But now, it doesn't work. It seems like I am missing
> > the
> > part that defines objMsg? How do I do this?
> > Also, I don't understand the reference of 'strFile =
> > "C:\Pictures\logo.gif"
> > because the picture I'm trying to paste is located on the web at strURL
> > Thanks for your patience with SouthernAtHeart!
>

>> Here's my code:
> > Sub InsertPicture()
>

>> strFile = "C:\Pictures\logo.gif"
> > Set objInsp = objMsg.GetInspector
> > Set objDoc = objInsp.WordEditor
> > Set objSel = objDoc.Windows(1).Selection
> > If objMsg.BodyFormat <> olFormatPlain Then
> > Set objShape = objSel.InlineShapes.AddPicture _
> > (strFile, False, True)
> > objDoc.Hyperlinks.Add objShape.Range, strURL
> > End If
> >

> "Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message
> news:e1mYnQFmKHA.1652@TK2MSFTNGP05.phx.gbl...
> > In that case, you can return a Word.Document using Inspector.WordEditor
> > and
> > then use Word methods to perform the insertion, something like this,
> > where
> > objMsg is the message you want to modify:
>

>> strFile = "C:\Pictures\logo.gif"
> > Set objInsp = objMsg.GetInspector
> > Set objDoc = objInsp.WordEditor
> > Set objSel = objDoc.Windows(1).Selection
> > If objMsg.BodyFormat <> olFormatPlain Then
> > Set objShape = objSel.InlineShapes.AddPicture _
> > (strFile, False, True)
> > objDoc.Hyperlinks.Add objShape.Range, strURL
> > End If
>

>> This technique would also work in Outlook 2007, which always uses Word as
> > the email editor.
>

>> "Southern at Heart" <SouthernatHeart> wrote in
> > message news:F957F25C-A831-4BDE-A415-36F86BB1C3CC@microsoft.com...
> >
>>> I have Outlook 2003, and I use Word 2003 as my email editor...
> >
>>>> > Via a custom tool bar button, I want to use vba to insert a picture
> >>> > into
> >>> > the
> >>> > body of my email (not an attachment). The picture's URL is strURL.
> >>> > Does
> >>> > anyone know how to do this?
 
S

Southern at Heart

I have the string strURL, which is the address of the picture. Just like the

example I gave:

strURL = http://www.google.com/intl/en_ALL/images/logo.gif

I don't know how to make this any clearer. I just want to paste a picture

into the body of my email, a picture that's located at the address strURL. I

don't have the picture on the clipboard, I don't have the picture on my

computer, I don't have the picture period. But it's located on the web, at

the address strURL. I don't want a link in my email that refers to the

picture, I want the picture itself. Maybe I'm asking something that is not

possible. Sorry, to be so confusing.

"Sue Mosher [MVP]" wrote:


> I'm confused. Do you have only the URL for the picture? Or do you have the
> picture on the clipboard, ready to paste?
> > Sue Mosher
> > >

> "Southern at Heart" <SouthernatHeart> wrote in
> message news:56CFCA24-FC2D-48BB-91EB-CCE170290AD3@microsoft.com...
> > Hi,
> > Let me explain more simply what I want to do:
> > I have strURL that is the location of a picture, say for example:
> > strURL = http://www.google.com/intl/en_ALL/images/logo.gif
> > ...I just want to 'paste' the image in the email body as a picture. I
> > don't
> > want the email to contain a link to the web based picture, but I want to
> > simply paste the picture just as if it were a picture on my PC that I
> > wanted
> > to paste into the email. I don't want the picture to be an attachment,
> > just
> > pasted in the body of the email.
> > Thank much! Sorry I'm not able to explain myself very well sometimes.
> >

> "Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message
> news:eBsuNwRmKHA.2780@TK2MSFTNGP05.phx.gbl...
> > I'm sorry, but I may have misinterpreted what you wanted to do. I thought
> > that you wanted to insert an image you already had and use it to link to
> > some location with strURL. But now it seems that you want to insert an
> > image
> > that only exists on the Internet. Is that correct? In general, this is not
> > a
> > good practice in email messages, because Outlook and many other mail
> > programs by default will not load content from the Internet, for security
> > and privacy reasons. Best practice is to embed the image into the message
> > from a file that already exists locally, as shown in the code I posted.
> > If you insist on using a web-based image, then you would need to modify
> > the
> > HTMLBody property of the message to insert an <img> tag at the desired
> > location, just the same as you would with a web page. The code sample at
> > http://www.outlookcode.com/codedetail.aspx?id=1358 shows how to insert an
> > HTML content string into the current cursor position, but I don't know
> > whether it will work if Word is the email editor. You'll have to try it
> > and
> > see.
> > "Southern at Heart" <SouthernatHeart> wrote in
> > message news:14C16A87-4E35-4102-9BFD-F712FEB6883F@microsoft.com...
> >>I don't understand everything I know about this!
> >
> >> In Outlook 2003, using Word 2003 as my editor, I click on the new message
> >> button to start a new email. It won't let me 'customize' the toolbar,
> >> but
> >> I
> >> see custom buttons up there that I made in Word. So I cut my code out of
> >> 'ThisOutlookSession' and opened up Word and pasted it in for Normal.dot,
> >> then
> >> I added a button on Word's toolbar to run it. I close Word, go back to
> >> Outlook, click New Email, and now I see my custom button! Hurray, I'm
> >> getting somewhere. But now, it doesn't work. It seems like I am missing
> >> the
> >> part that defines objMsg? How do I do this?
> >> Also, I don't understand the reference of 'strFile =
> >> "C:\Pictures\logo.gif"
> >> because the picture I'm trying to paste is located on the web at strURL
> >> Thanks for your patience with SouthernAtHeart!
> >
> >> Here's my code:
> >> Sub InsertPicture()
> >
> >> strFile = "C:\Pictures\logo.gif"
> >> Set objInsp = objMsg.GetInspector
> >> Set objDoc = objInsp.WordEditor
> >> Set objSel = objDoc.Windows(1).Selection
> >> If objMsg.BodyFormat <> olFormatPlain Then
> >> Set objShape = objSel.InlineShapes.AddPicture _
> >> (strFile, False, True)
> >> objDoc.Hyperlinks.Add objShape.Range, strURL
> >> End If
> >>

> > "Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message
> > news:e1mYnQFmKHA.1652@TK2MSFTNGP05.phx.gbl...
> >> In that case, you can return a Word.Document using Inspector.WordEditor
> >> and
> >> then use Word methods to perform the insertion, something like this,
> >> where
> >> objMsg is the message you want to modify:
> >
> >> strFile = "C:\Pictures\logo.gif"
> >> Set objInsp = objMsg.GetInspector
> >> Set objDoc = objInsp.WordEditor
> >> Set objSel = objDoc.Windows(1).Selection
> >> If objMsg.BodyFormat <> olFormatPlain Then
> >> Set objShape = objSel.InlineShapes.AddPicture _
> >> (strFile, False, True)
> >> objDoc.Hyperlinks.Add objShape.Range, strURL
> >> End If
> >
> >> This technique would also work in Outlook 2007, which always uses Word as
> >> the email editor.
> >
> >> "Southern at Heart" <SouthernatHeart> wrote in
> >> message news:F957F25C-A831-4BDE-A415-36F86BB1C3CC@microsoft.com...
> >>
> >>> I have Outlook 2003, and I use Word 2003 as my email editor...
> >>
> >>>> > Via a custom tool bar button, I want to use vba to insert a picture
> >>>> > into
> >>>> > the
> >>>> > body of my email (not an attachment). The picture's URL is strURL.
> >>>> > Does
> >>>> > anyone know how to do this?


> .
>
 
S

Sue Mosher [MVP]

If you don't have the picture on your clipboard, then you can't paste it, by

definition.

If all you have is the web URL, then you have two choices:

1) Download the picture to your computer so you can use the Word method

proposed to you. I cannot help you with the code to download the picture

programmatically, because I don't know how to do that.

2) Insert the picture as an <img> tag, using the HTMLEditor method proposed

to you.

Sue Mosher

"Southern at Heart" <SouthernatHeart> wrote in

message news:328F0577-3F46-4741-AD04-36EEA37D6079@microsoft.com...
> I have the string strURL, which is the address of the picture. Just like
> the
> example I gave:

> strURL = http://www.google.com/intl/en_ALL/images/logo.gif

> I don't know how to make this any clearer. I just want to paste a picture
> into the body of my email, a picture that's located at the address strURL.
> I
> don't have the picture on the clipboard, I don't have the picture on my
> computer, I don't have the picture period. But it's located on the web,
> at
> the address strURL. I don't want a link in my email that refers to the
> picture, I want the picture itself. Maybe I'm asking something that is
> not
> possible. Sorry, to be so confusing.

> "Sue Mosher [MVP]" wrote:
>
> > I'm confused. Do you have only the URL for the picture? Or do you have
> > the
> > picture on the clipboard, ready to paste?
>

>> "Southern at Heart" <SouthernatHeart> wrote in
> > message news:56CFCA24-FC2D-48BB-91EB-CCE170290AD3@microsoft.com...
> > > Hi,
> > > Let me explain more simply what I want to do:
> > > I have strURL that is the location of a picture, say for example:
> > > strURL = http://www.google.com/intl/en_ALL/images/logo.gif
> >> > ...I just want to 'paste' the image in the email body as a picture. I
> > > don't
> > > want the email to contain a link to the web based picture, but I want
> > > to
> > > simply paste the picture just as if it were a picture on my PC that I
> > > wanted
> > > to paste into the email. I don't want the picture to be an attachment,
> > > just
> > > pasted in the body of the email.
> > > Thank much! Sorry I'm not able to explain myself very well sometimes.
> > >

> > "Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message
> > news:eBsuNwRmKHA.2780@TK2MSFTNGP05.phx.gbl...
> > > I'm sorry, but I may have misinterpreted what you wanted to do. I
> > > thought
> > > that you wanted to insert an image you already had and use it to link
> > > to
> > > some location with strURL. But now it seems that you want to insert an
> > > image
> > > that only exists on the Internet. Is that correct? In general, this is
> > > not
> > > a
> > > good practice in email messages, because Outlook and many other mail
> > > programs by default will not load content from the Internet, for
> > > security
> > > and privacy reasons. Best practice is to embed the image into the
> > > message
> > > from a file that already exists locally, as shown in the code I posted.
> >> > If you insist on using a web-based image, then you would need to modify
> > > the
> > > HTMLBody property of the message to insert an <img> tag at the desired
> > > location, just the same as you would with a web page. The code sample
> > > at
> > > http://www.outlookcode.com/codedetail.aspx?id=1358 shows how to insert
> > > an
> > > HTML content string into the current cursor position, but I don't know
> > > whether it will work if Word is the email editor. You'll have to try it
> > > and
> > > see.
> >> > "Southern at Heart" <SouthernatHeart> wrote
> > > in
> > > message news:14C16A87-4E35-4102-9BFD-F712FEB6883F@microsoft.com...
> > >>I don't understand everything I know about this!
> > >
>> >> In Outlook 2003, using Word 2003 as my editor, I click on the new
> > >> message
> > >> button to start a new email. It won't let me 'customize' the toolbar,
> > >> but
> > >> I
> > >> see custom buttons up there that I made in Word. So I cut my code out
> > >> of
> > >> 'ThisOutlookSession' and opened up Word and pasted it in for
> > >> Normal.dot,
> > >> then
> > >> I added a button on Word's toolbar to run it. I close Word, go back
> > >> to
> > >> Outlook, click New Email, and now I see my custom button! Hurray, I'm
> > >> getting somewhere. But now, it doesn't work. It seems like I am
> > >> missing
> > >> the
> > >> part that defines objMsg? How do I do this?
> > >> Also, I don't understand the reference of 'strFile =
> > >> "C:\Pictures\logo.gif"
> > >> because the picture I'm trying to paste is located on the web at
> > >> strURL
> > >> Thanks for your patience with SouthernAtHeart!
> > >
>> >> Here's my code:
> > >> Sub InsertPicture()
> > >
>> >> strFile = "C:\Pictures\logo.gif"
> > >> Set objInsp = objMsg.GetInspector
> > >> Set objDoc = objInsp.WordEditor
> > >> Set objSel = objDoc.Windows(1).Selection
> > >> If objMsg.BodyFormat <> olFormatPlain Then
> > >> Set objShape = objSel.InlineShapes.AddPicture _
> > >> (strFile, False, True)
> > >> objDoc.Hyperlinks.Add objShape.Range, strURL
> > >> End If
> > >
>> > "Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message
> > > news:e1mYnQFmKHA.1652@TK2MSFTNGP05.phx.gbl...
> > >> In that case, you can return a Word.Document using
> > >> Inspector.WordEditor
> > >> and
> > >> then use Word methods to perform the insertion, something like this,
> > >> where
> > >> objMsg is the message you want to modify:
> > >
>> >> strFile = "C:\Pictures\logo.gif"
> > >> Set objInsp = objMsg.GetInspector
> > >> Set objDoc = objInsp.WordEditor
> > >> Set objSel = objDoc.Windows(1).Selection
> > >> If objMsg.BodyFormat <> olFormatPlain Then
> > >> Set objShape = objSel.InlineShapes.AddPicture _
> > >> (strFile, False, True)
> > >> objDoc.Hyperlinks.Add objShape.Range, strURL
> > >> End If
> > >
>> >> This technique would also work in Outlook 2007, which always uses Word
> > >> as
> > >> the email editor.
> > >
>> >> "Southern at Heart" <SouthernatHeart> wrote
> > >> in
> > >> message news:F957F25C-A831-4BDE-A415-36F86BB1C3CC@microsoft.com...
> > >>
>> >>> I have Outlook 2003, and I use Word 2003 as my email editor...
> > >>
>> >>>> > Via a custom tool bar button, I want to use vba to insert a
> > >>>> > picture
> > >>>> > into
> > >>>> > the
> > >>>> > body of my email (not an attachment). The picture's URL is
> > >>>> > strURL.
> > >>>> > Does
> > >>>> > anyone know how to do this?

>

>
>> .
> >
 
S

Southern at Heart

Is this possible to do?

thanks

"Southern at Heart" wrote:


> I have the string strURL, which is the address of the picture. Just like the
> example I gave:

> strURL = http://www.google.com/intl/en_ALL/images/logo.gif

> I don't know how to make this any clearer. I just want to paste a picture
> into the body of my email, a picture that's located at the address strURL. I
> don't have the picture on the clipboard, I don't have the picture on my
> computer, I don't have the picture period. But it's located on the web, at
> the address strURL. I don't want a link in my email that refers to the
> picture, I want the picture itself. Maybe I'm asking something that is not
> possible. Sorry, to be so confusing.

> "Sue Mosher [MVP]" wrote:
>
> > I'm confused. Do you have only the URL for the picture? Or do you have the
> > picture on the clipboard, ready to paste?
> > > > Sue Mosher
> > > > > > > > "Southern at Heart" <SouthernatHeart> wrote in
> > message news:56CFCA24-FC2D-48BB-91EB-CCE170290AD3@microsoft.com...
> > > Hi,
> > > Let me explain more simply what I want to do:
> > > I have strURL that is the location of a picture, say for example:
> > > strURL = http://www.google.com/intl/en_ALL/images/logo.gif
> > > > ...I just want to 'paste' the image in the email body as a picture. I
> > > don't
> > > want the email to contain a link to the web based picture, but I want to
> > > simply paste the picture just as if it were a picture on my PC that I
> > > wanted
> > > to paste into the email. I don't want the picture to be an attachment,
> > > just
> > > pasted in the body of the email.
> > > Thank much! Sorry I'm not able to explain myself very well sometimes.
> > >

> > "Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message
> > news:eBsuNwRmKHA.2780@TK2MSFTNGP05.phx.gbl...
> > > I'm sorry, but I may have misinterpreted what you wanted to do. I thought
> > > that you wanted to insert an image you already had and use it to link to
> > > some location with strURL. But now it seems that you want to insert an
> > > image
> > > that only exists on the Internet. Is that correct? In general, this is not
> > > a
> > > good practice in email messages, because Outlook and many other mail
> > > programs by default will not load content from the Internet, for security
> > > and privacy reasons. Best practice is to embed the image into the message
> > > from a file that already exists locally, as shown in the code I posted.
> > > > If you insist on using a web-based image, then you would need to modify
> > > the
> > > HTMLBody property of the message to insert an <img> tag at the desired
> > > location, just the same as you would with a web page. The code sample at
> > > http://www.outlookcode.com/codedetail.aspx?id=1358 shows how to insert an
> > > HTML content string into the current cursor position, but I don't know
> > > whether it will work if Word is the email editor. You'll have to try it
> > > and
> > > see.
> > > > "Southern at Heart" <SouthernatHeart> wrote in
> > > message news:14C16A87-4E35-4102-9BFD-F712FEB6883F@microsoft.com...
> > >>I don't understand everything I know about this!
> > >
> > >> In Outlook 2003, using Word 2003 as my editor, I click on the new message
> > >> button to start a new email. It won't let me 'customize' the toolbar,
> > >> but
> > >> I
> > >> see custom buttons up there that I made in Word. So I cut my code out of
> > >> 'ThisOutlookSession' and opened up Word and pasted it in for Normal.dot,
> > >> then
> > >> I added a button on Word's toolbar to run it. I close Word, go back to
> > >> Outlook, click New Email, and now I see my custom button! Hurray, I'm
> > >> getting somewhere. But now, it doesn't work. It seems like I am missing
> > >> the
> > >> part that defines objMsg? How do I do this?
> > >> Also, I don't understand the reference of 'strFile =
> > >> "C:\Pictures\logo.gif"
> > >> because the picture I'm trying to paste is located on the web at strURL
> > >> Thanks for your patience with SouthernAtHeart!
> > >
> > >> Here's my code:
> > >> Sub InsertPicture()
> > >
> > >> strFile = "C:\Pictures\logo.gif"
> > >> Set objInsp = objMsg.GetInspector
> > >> Set objDoc = objInsp.WordEditor
> > >> Set objSel = objDoc.Windows(1).Selection
> > >> If objMsg.BodyFormat <> olFormatPlain Then
> > >> Set objShape = objSel.InlineShapes.AddPicture _
> > >> (strFile, False, True)
> > >> objDoc.Hyperlinks.Add objShape.Range, strURL
> > >> End If
> > >
> > > "Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message
> > > news:e1mYnQFmKHA.1652@TK2MSFTNGP05.phx.gbl...
> > >> In that case, you can return a Word.Document using Inspector.WordEditor
> > >> and
> > >> then use Word methods to perform the insertion, something like this,
> > >> where
> > >> objMsg is the message you want to modify:
> > >
> > >> strFile = "C:\Pictures\logo.gif"
> > >> Set objInsp = objMsg.GetInspector
> > >> Set objDoc = objInsp.WordEditor
> > >> Set objSel = objDoc.Windows(1).Selection
> > >> If objMsg.BodyFormat <> olFormatPlain Then
> > >> Set objShape = objSel.InlineShapes.AddPicture _
> > >> (strFile, False, True)
> > >> objDoc.Hyperlinks.Add objShape.Range, strURL
> > >> End If
> > >
> > >> This technique would also work in Outlook 2007, which always uses Word as
> > >> the email editor.
> > >
> > >> "Southern at Heart" <SouthernatHeart> wrote in
> > >> message news:F957F25C-A831-4BDE-A415-36F86BB1C3CC@microsoft.com...
> > >>
> > >>> I have Outlook 2003, and I use Word 2003 as my email editor...
> > >>
> > >>>> > Via a custom tool bar button, I want to use vba to insert a picture
> > >>>> > into
> > >>>> > the
> > >>>> > body of my email (not an attachment). The picture's URL is strURL.
> > >>>> > Does
> > >>>> > anyone know how to do this?

> > .
> >
 
S

Sue Mosher [MVP]

Please see my latest response to your earlier post.

Sue Mosher

"Southern at Heart" <SouthernatHeart> wrote in

message news:AD488321-406D-449A-924D-483205A1BF38@microsoft.com...
> Is this possible to do?
> thanks

> "Southern at Heart" wrote:
>
> > I have the string strURL, which is the address of the picture. Just like
> > the
> > example I gave:
>

>> strURL = http://www.google.com/intl/en_ALL/images/logo.gif
>

>> I don't know how to make this any clearer. I just want to paste a
> > picture
> > into the body of my email, a picture that's located at the address
> > strURL. I
> > don't have the picture on the clipboard, I don't have the picture on my
> > computer, I don't have the picture period. But it's located on the web,
> > at
> > the address strURL. I don't want a link in my email that refers to the
> > picture, I want the picture itself. Maybe I'm asking something that is
> > not
> > possible. Sorry, to be so confusing.
>

>
>
>> "Sue Mosher [MVP]" wrote:
> >
> > > I'm confused. Do you have only the URL for the picture? Or do you have
> > > the
> > > picture on the clipboard, ready to paste?
> > > > > > Sue Mosher
> > > >> > >> > >>>> > "Southern at Heart" <SouthernatHeart> wrote
> > > in
> > > message news:56CFCA24-FC2D-48BB-91EB-CCE170290AD3@microsoft.com...
> > > > Hi,
> > > > Let me explain more simply what I want to do:
> > > > I have strURL that is the location of a picture, say for example:
> > > > strURL = http://www.google.com/intl/en_ALL/images/logo.gif
> > >> > > ...I just want to 'paste' the image in the email body as a picture.
> > > > I
> > > > don't
> > > > want the email to contain a link to the web based picture, but I want
> > > > to
> > > > simply paste the picture just as if it were a picture on my PC that I
> > > > wanted
> > > > to paste into the email. I don't want the picture to be an
> > > > attachment,
> > > > just
> > > > pasted in the body of the email.
> > > > Thank much! Sorry I'm not able to explain myself very well
> > > > sometimes.
> > >> > "Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message
> > > news:eBsuNwRmKHA.2780@TK2MSFTNGP05.phx.gbl...
> > > > I'm sorry, but I may have misinterpreted what you wanted to do. I
> > > > thought
> > > > that you wanted to insert an image you already had and use it to link
> > > > to
> > > > some location with strURL. But now it seems that you want to insert
> > > > an
> > > > image
> > > > that only exists on the Internet. Is that correct? In general, this
> > > > is not
> > > > a
> > > > good practice in email messages, because Outlook and many other mail
> > > > programs by default will not load content from the Internet, for
> > > > security
> > > > and privacy reasons. Best practice is to embed the image into the
> > > > message
> > > > from a file that already exists locally, as shown in the code I
> > > > posted.
> > >> > > If you insist on using a web-based image, then you would need to
> > > > modify
> > > > the
> > > > HTMLBody property of the message to insert an <img> tag at the
> > > > desired
> > > > location, just the same as you would with a web page. The code sample
> > > > at
> > > > http://www.outlookcode.com/codedetail.aspx?id=1358 shows how to
> > > > insert an
> > > > HTML content string into the current cursor position, but I don't
> > > > know
> > > > whether it will work if Word is the email editor. You'll have to try
> > > > it
> > > > and
> > > > see.
> > >> > > "Southern at Heart" <SouthernatHeart> wrote
> > > > in
> > > > message news:14C16A87-4E35-4102-9BFD-F712FEB6883F@microsoft.com...
> > > >>I don't understand everything I know about this!
> > > >
>> > >> In Outlook 2003, using Word 2003 as my editor, I click on the new
> > > >> message
> > > >> button to start a new email. It won't let me 'customize' the
> > > >> toolbar,
> > > >> but
> > > >> I
> > > >> see custom buttons up there that I made in Word. So I cut my code
> > > >> out of
> > > >> 'ThisOutlookSession' and opened up Word and pasted it in for
> > > >> Normal.dot,
> > > >> then
> > > >> I added a button on Word's toolbar to run it. I close Word, go back
> > > >> to
> > > >> Outlook, click New Email, and now I see my custom button! Hurray,
> > > >> I'm
> > > >> getting somewhere. But now, it doesn't work. It seems like I am
> > > >> missing
> > > >> the
> > > >> part that defines objMsg? How do I do this?
> > > >> Also, I don't understand the reference of 'strFile =
> > > >> "C:\Pictures\logo.gif"
> > > >> because the picture I'm trying to paste is located on the web at
> > > >> strURL
> > > >> Thanks for your patience with SouthernAtHeart!
> > > >
>> > >> Here's my code:
> > > >> Sub InsertPicture()
> > > >
>> > >> strFile = "C:\Pictures\logo.gif"
> > > >> Set objInsp = objMsg.GetInspector
> > > >> Set objDoc = objInsp.WordEditor
> > > >> Set objSel = objDoc.Windows(1).Selection
> > > >> If objMsg.BodyFormat <> olFormatPlain Then
> > > >> Set objShape = objSel.InlineShapes.AddPicture _
> > > >> (strFile, False, True)
> > > >> objDoc.Hyperlinks.Add objShape.Range, strURL
> > > >> End If
> > > >
>> > > "Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message
> > > > news:e1mYnQFmKHA.1652@TK2MSFTNGP05.phx.gbl...
> > > >> In that case, you can return a Word.Document using
> > > >> Inspector.WordEditor
> > > >> and
> > > >> then use Word methods to perform the insertion, something like this,
> > > >> where
> > > >> objMsg is the message you want to modify:
> > > >
>> > >> strFile = "C:\Pictures\logo.gif"
> > > >> Set objInsp = objMsg.GetInspector
> > > >> Set objDoc = objInsp.WordEditor
> > > >> Set objSel = objDoc.Windows(1).Selection
> > > >> If objMsg.BodyFormat <> olFormatPlain Then
> > > >> Set objShape = objSel.InlineShapes.AddPicture _
> > > >> (strFile, False, True)
> > > >> objDoc.Hyperlinks.Add objShape.Range, strURL
> > > >> End If
> > > >
>> > >> This technique would also work in Outlook 2007, which always uses
> > > >> Word as
> > > >> the email editor.
> > > >
>> > >> "Southern at Heart" <SouthernatHeart
>> > >> wrote in
> > > >> message news:F957F25C-A831-4BDE-A415-36F86BB1C3CC@microsoft.com...
> > > >>
>> > >>> I have Outlook 2003, and I use Word 2003 as my email editor...
> > > >>
>> > >>>> > Via a custom tool bar button, I want to use vba to insert a
> > > >>>> > picture
> > > >>>> > into
> > > >>>> > the
> > > >>>> > body of my email (not an attachment). The picture's URL is
> > > >>>> > strURL.
> > > >>>> > Does
> > > >>>> > anyone know how to do this?
> >>> > .
> > >
 
S

Southern at Heart

Thanks, I didn't see that post. I try finding out how to get the picture

onto the clipboard...

cheers.

"Sue Mosher [MVP]" wrote:


> Please see my latest response to your earlier post.

> > Sue Mosher
> > >

> "Southern at Heart" <SouthernatHeart> wrote in
> message news:AD488321-406D-449A-924D-483205A1BF38@microsoft.com...
> > Is this possible to do?
> > thanks
> > "Southern at Heart" wrote:
> >
> >> I have the string strURL, which is the address of the picture. Just like
> >> the
> >> example I gave:
> >
> >> strURL = http://www.google.com/intl/en_ALL/images/logo.gif
> >
> >> I don't know how to make this any clearer. I just want to paste a
> >> picture
> >> into the body of my email, a picture that's located at the address
> >> strURL. I
> >> don't have the picture on the clipboard, I don't have the picture on my
> >> computer, I don't have the picture period. But it's located on the web,
> >> at
> >> the address strURL. I don't want a link in my email that refers to the
> >> picture, I want the picture itself. Maybe I'm asking something that is
> >> not
> >> possible. Sorry, to be so confusing.
> >
> >
> >
> >> "Sue Mosher [MVP]" wrote:
> >
> >> > I'm confused. Do you have only the URL for the picture? Or do you have
> >> > the
> >> > picture on the clipboard, ready to paste?
> >> > > >> > Sue Mosher
> >> > > >> > > >> > > >> >> >> > "Southern at Heart" <SouthernatHeart> wrote
> >> > in
> >> > message news:56CFCA24-FC2D-48BB-91EB-CCE170290AD3@microsoft.com...
> >> > > Hi,
> >> > > Let me explain more simply what I want to do:
> >> > > I have strURL that is the location of a picture, say for example:
> >> > > strURL = http://www.google.com/intl/en_ALL/images/logo.gif
> >> > >> > > ...I just want to 'paste' the image in the email body as a picture.
> >> > > I
> >> > > don't
> >> > > want the email to contain a link to the web based picture, but I want
> >> > > to
> >> > > simply paste the picture just as if it were a picture on my PC that I
> >> > > wanted
> >> > > to paste into the email. I don't want the picture to be an
> >> > > attachment,
> >> > > just
> >> > > pasted in the body of the email.
> >> > > Thank much! Sorry I'm not able to explain myself very well
> >> > > sometimes.
> >> > >> > "Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message
> >> > news:eBsuNwRmKHA.2780@TK2MSFTNGP05.phx.gbl...
> >> > > I'm sorry, but I may have misinterpreted what you wanted to do. I
> >> > > thought
> >> > > that you wanted to insert an image you already had and use it to link
> >> > > to
> >> > > some location with strURL. But now it seems that you want to insert
> >> > > an
> >> > > image
> >> > > that only exists on the Internet. Is that correct? In general, this
> >> > > is not
> >> > > a
> >> > > good practice in email messages, because Outlook and many other mail
> >> > > programs by default will not load content from the Internet, for
> >> > > security
> >> > > and privacy reasons. Best practice is to embed the image into the
> >> > > message
> >> > > from a file that already exists locally, as shown in the code I
> >> > > posted.
> >> > >> > > If you insist on using a web-based image, then you would need to
> >> > > modify
> >> > > the
> >> > > HTMLBody property of the message to insert an <img> tag at the
> >> > > desired
> >> > > location, just the same as you would with a web page. The code sample
> >> > > at
> >> > > http://www.outlookcode.com/codedetail.aspx?id=1358 shows how to
> >> > > insert an
> >> > > HTML content string into the current cursor position, but I don't
> >> > > know
> >> > > whether it will work if Word is the email editor. You'll have to try
> >> > > it
> >> > > and
> >> > > see.
> >> > >> > > "Southern at Heart" <SouthernatHeart> wrote
> >> > > in
> >> > > message news:14C16A87-4E35-4102-9BFD-F712FEB6883F@microsoft.com...
> >> > >>I don't understand everything I know about this!
> >> > >
> >> > >> In Outlook 2003, using Word 2003 as my editor, I click on the new
> >> > >> message
> >> > >> button to start a new email. It won't let me 'customize' the
> >> > >> toolbar,
> >> > >> but
> >> > >> I
> >> > >> see custom buttons up there that I made in Word. So I cut my code
> >> > >> out of
> >> > >> 'ThisOutlookSession' and opened up Word and pasted it in for
> >> > >> Normal.dot,
> >> > >> then
> >> > >> I added a button on Word's toolbar to run it. I close Word, go back
> >> > >> to
> >> > >> Outlook, click New Email, and now I see my custom button! Hurray,
> >> > >> I'm
> >> > >> getting somewhere. But now, it doesn't work. It seems like I am
> >> > >> missing
> >> > >> the
> >> > >> part that defines objMsg? How do I do this?
> >> > >> Also, I don't understand the reference of 'strFile =
> >> > >> "C:\Pictures\logo.gif"
> >> > >> because the picture I'm trying to paste is located on the web at
> >> > >> strURL
> >> > >> Thanks for your patience with SouthernAtHeart!
> >> > >
> >> > >> Here's my code:
> >> > >> Sub InsertPicture()
> >> > >
> >> > >> strFile = "C:\Pictures\logo.gif"
> >> > >> Set objInsp = objMsg.GetInspector
> >> > >> Set objDoc = objInsp.WordEditor
> >> > >> Set objSel = objDoc.Windows(1).Selection
> >> > >> If objMsg.BodyFormat <> olFormatPlain Then
> >> > >> Set objShape = objSel.InlineShapes.AddPicture _
> >> > >> (strFile, False, True)
> >> > >> objDoc.Hyperlinks.Add objShape.Range, strURL
> >> > >> End If
> >> > >
> >> > > "Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message
> >> > > news:e1mYnQFmKHA.1652@TK2MSFTNGP05.phx.gbl...
> >> > >> In that case, you can return a Word.Document using
> >> > >> Inspector.WordEditor
> >> > >> and
> >> > >> then use Word methods to perform the insertion, something like this,
> >> > >> where
> >> > >> objMsg is the message you want to modify:
> >> > >
> >> > >> strFile = "C:\Pictures\logo.gif"
> >> > >> Set objInsp = objMsg.GetInspector
> >> > >> Set objDoc = objInsp.WordEditor
> >> > >> Set objSel = objDoc.Windows(1).Selection
> >> > >> If objMsg.BodyFormat <> olFormatPlain Then
> >> > >> Set objShape = objSel.InlineShapes.AddPicture _
> >> > >> (strFile, False, True)
> >> > >> objDoc.Hyperlinks.Add objShape.Range, strURL
> >> > >> End If
> >> > >
> >> > >> This technique would also work in Outlook 2007, which always uses
> >> > >> Word as
> >> > >> the email editor.
> >> > >
> >> > >> "Southern at Heart" <SouthernatHeart
> >> > >> wrote in
> >> > >> message news:F957F25C-A831-4BDE-A415-36F86BB1C3CC@microsoft.com...
> >> > >>
> >> > >>> I have Outlook 2003, and I use Word 2003 as my email editor...
> >> > >>
> >> > >>>> > Via a custom tool bar button, I want to use vba to insert a
> >> > >>>> > picture
> >> > >>>> > into
> >> > >>>> > the
> >> > >>>> > body of my email (not an attachment). The picture's URL is
> >> > >>>> > strURL.
> >> > >>>> > Does
> >> > >>>> > anyone know how to do this?
> >> >> >> > .
> >> >


> .
>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
R insert picture tab grey Using Outlook 1
C insert a picture Outlook VBA and Custom Forms 1
B VBA to convert email to task, insert text of email in task notes, and attach copy of original email Outlook VBA and Custom Forms 4
B Programmatically force html send and insert clipboard contents into body Outlook VBA and Custom Forms 0
P Auto Insert Current Date or Time into Email Subject Outlook VBA and Custom Forms 2
witzker Outlook 2010 Insert Date & Time at the button of an OL contactform in red Using Outlook 2
P Insert link in email body to attached document in Outlook 365 Outlook VBA and Custom Forms 0
E Copy e-mail body from outlook and insert into excel Outlook VBA and Custom Forms 3
R How Do I insert images in and Auto Reply Using Outlook 3
L Automatically Insert Recipient Name from To Field Outlook VBA and Custom Forms 33
Diane Poremsky Create Task or Appointment and Insert Selected Text New Slipstick.com Articles 0
B Insert Hyperlinks for attachments in Userform Outlook VBA and Custom Forms 5
D Outlook task insert Outlook VBA and Custom Forms 3
A Auto Insert of filename when selecting 'Remove Attachment' Using Outlook 1
K Insert screenshots issue Using Outlook 2
makinmyway Recent Files Not Updating when Using Insert Hyperlink in Outlook 2013 Using Outlook 0
L Insert Photo to Contact Using Outlook 23
K OL2010 Button to Insert First Name Outlook VBA and Custom Forms 6
K OL2010 Button to Insert First Name Using Outlook 1
witzker insert Date & Time (HH:mm) no (ss) in userform Using Outlook 6
A insert Date & Time in userform Using Outlook 3
K Macro to insert attachments Using Outlook 1
C Insert a Date Picker for Send Mail Subject Using Outlook 1
C Insert date in Subject through date picker Using Outlook 0
mrje1 Opening a task the Insert Tab Option is not showing up and organizing Tasks Using Outlook 9
H Insert Specific Text before Subject for New mails and reply Using Outlook 3
K Outlook insert clip art, no results found...address book contacts only show up Using Outlook 5
J Form design - how do I insert an automatic date/time field? Using Outlook 2
J How do I view the ruler in an Outlook message and/or insert tabs? Using Outlook 7
L Forward Email and Insert Sender's Email address in body Outlook VBA and Custom Forms 3
D Insert Text and Send Outlook VBA and Custom Forms 1
D Re: How do i insert radio buttons in an email Outlook VBA and Custom Forms 1
G How to insert a json array into a calendar events Outlook VBA and Custom Forms 1
K insert text into current position of pointer in mailcompose Outlook VBA and Custom Forms 1
J Insert File Outlook VBA and Custom Forms 2
M Insert a File Outlook VBA and Custom Forms 3
G Task / Insert / Attach Item / Business Contact BCM (Business Contact Manager) 1
M Forward email as insert from button Outlook VBA and Custom Forms 1
B Simple way to insert file text - macro? Outlook VBA and Custom Forms 1
J How do I scan and insert into Outlook 2007? Using Outlook 3
B Insert information to MailItem Outlook VBA and Custom Forms 1
D RE: How do you change the default insert file path in outlook? Using Outlook 11
D Insert Text via Macro in Outlook 2007 Outlook VBA and Custom Forms 2
T Is it possible to INSERT a string into email body via Shortcut. Outlook VBA and Custom Forms 2
J Command Button to insert Email Signature Outlook VBA and Custom Forms 2
D Macro creation for Outlook insert subject Outlook VBA and Custom Forms 1
F Insert date at cursor location Outlook VBA and Custom Forms 4
T Insert text from file Outlook VBA and Custom Forms 1
S How to create a macro to insert a signature in Outlook 2007 Outlook VBA and Custom Forms 1
T How do i insert a page break in an Outlook e-mail message? Using Outlook 4

Similar threads

Top