A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

HTMLBody with images



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 31st 07, 01:44 AM posted to microsoft.public.outlook.program_vba
tim johnson
external usenet poster
 
Posts: 4
Default HTMLBody with images

Hi there,

I am working on the development of a database (Access). I think that
because the issues I'm having are outlook related, though, that this is the
appropriate place for posting this.

I use a VBA sub to create an instance of Outlook by which I send
"personalized" emails. Most of these emails are designed using Word and
include images, then are saved as HTML files. My code is currently:

Set FSO = CreateObject("Scripting.FileSystemObject")
Set bdy = FSO.OpenTextFile(strFile,1)
strText = bdy.readall

With objMail
.To = strTo
.Subject = strSubject
.HTMLBody = strText
.Send
End With

The email's body & formatting come through just fine, but the images are
broken links (it appears from the source as though they're tring to link to a
local location).

Is there a way to include the images without having to post them on the
internet each time?

Thanks in advance
Ads
  #2  
Old January 31st 07, 06:56 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default HTMLBody with images


Here's a sample, based on a template from Dmitry Streblchenko:
http://www.vboffice.net/sample.html?...9&cmd=showitem

For that sample you need the Redemption (www.dimastr.com).

Call AddEmbeddedAttachment with

- Mail: Outlook MailItem
- File: Full file name of the image file
- [PositionID]: You can insert a placeholder into the e-mails HTMLBody and
pass that placeholder here. The image then would be placed at that position.
If there's no placeholder the image would be inserted at the end.
- [Description]: Optional description for the image


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Keep your Outlook categories organized!
http://www.shareit.com/product.html?...4&languageid=1
(German: http://www.VBOffice.net/product.html?pub=6)


Am Tue, 30 Jan 2007 16:44:00 -0800 schrieb Tim Johnson:

Hi there,

I am working on the development of a database (Access). I think that
because the issues I'm having are outlook related, though, that this is

the
appropriate place for posting this.

I use a VBA sub to create an instance of Outlook by which I send
"personalized" emails. Most of these emails are designed using Word and
include images, then are saved as HTML files. My code is currently:

Set FSO = CreateObject("Scripting.FileSystemObject")
Set bdy = FSO.OpenTextFile(strFile,1)
strText = bdy.readall

With objMail
.To = strTo
.Subject = strSubject
.HTMLBody = strText
.Send
End With

The email's body & formatting come through just fine, but the images are
broken links (it appears from the source as though they're tring to link

to a
local location).

Is there a way to include the images without having to post them on the
internet each time?

Thanks in advance

  #3  
Old January 31st 07, 09:15 AM posted to microsoft.public.outlook.program_vba
tim johnson
external usenet poster
 
Posts: 4
Default HTMLBody with images

Thank you for your rapid response, Michael.

Unfortunately, I'm doing this as a favor for a friend, and am not able to
drop $200 on Redemption for this project.

I have made some code that will actually link to the url's after being
unable to find answers on the web (I've pasted my code below), but it's very
limited (and, at the moment, requires the original images to be jpg files).
If anyone knows where I can find some more efficient solutions, please let me
know. Here's the code:

Set FSO = CreateObject("Scripting.FileSystemObject")
Set bdy = FSO.OpenTextFile(strFile)
strText = bdy.readall

intSearch = 1
intPicNum = 0
strText = Right(strText, Len(strText) - InStr(1, strText, "body") + 1)
Do While intSearch Len(strText)
If InStr(intSearch, strText, "img") = 0 Then
intSearch = Len(strText)
Else:
intSearch = InStr(intSearch, strText, "img")
intPicNum = intPicNum + 1
MsgBox (InStr(intSearch, strText, "jpg"))
MsgBox (InStr(intSearch + 70, strText, "jpg"))
strText = Left(strText, InStr(intSearch, strText, "src=") + 4) &
InputBox_("Pictures sent through this utility MUST be linked to a picture on
the internet." &_ Chr(13) & "Please enter the FULL web address for picture
no. " &_ intPicNum, "Picture Location") & Right(strText, Len(strText) -
InStr(intSearch,_ strText, "jpg") - 2)
intSearch = intSearch + 4
End If
Loop

Do While IsNull(Me.Email) = False
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = CreateItem(olMailItem)

With objMail
.To = strTo
.Subject = strSubject
.HTMLBody = strText
.Send
End With
DoCmd.GoToRecord , , acNext
Loop


I hope this helps someone who may stumble on this...it's still pretty
limited, though.

"Michael Bauer [MVP - Outlook]" wrote:


Here's a sample, based on a template from Dmitry Streblchenko:
http://www.vboffice.net/sample.html?...9&cmd=showitem

For that sample you need the Redemption (www.dimastr.com).

Call AddEmbeddedAttachment with

- Mail: Outlook MailItem
- File: Full file name of the image file
- [PositionID]: You can insert a placeholder into the e-mails HTMLBody and
pass that placeholder here. The image then would be placed at that position.
If there's no placeholder the image would be inserted at the end.
- [Description]: Optional description for the image


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Keep your Outlook categories organized!
http://www.shareit.com/product.html?...4&languageid=1
(German: http://www.VBOffice.net/product.html?pub=6)


Am Tue, 30 Jan 2007 16:44:00 -0800 schrieb Tim Johnson:

Hi there,

I am working on the development of a database (Access). I think that
because the issues I'm having are outlook related, though, that this is

the
appropriate place for posting this.

I use a VBA sub to create an instance of Outlook by which I send
"personalized" emails. Most of these emails are designed using Word and
include images, then are saved as HTML files. My code is currently:

Set FSO = CreateObject("Scripting.FileSystemObject")
Set bdy = FSO.OpenTextFile(strFile,1)
strText = bdy.readall

With objMail
.To = strTo
.Subject = strSubject
.HTMLBody = strText
.Send
End With

The email's body & formatting come through just fine, but the images are
broken links (it appears from the source as though they're tring to link

to a
local location).

Is there a way to include the images without having to post them on the
internet each time?

Thanks in advance


  #4  
Old January 31st 07, 09:26 AM posted to microsoft.public.outlook.program_vba
tim johnson
external usenet poster
 
Posts: 4
Default HTMLBody with images

Ooops...apparently I left some testing MsgBox's in there! Lol. Also, if
someone does decide to use this in conjunction with Word, be sure to save
your document as Formatted HTML.

"Tim Johnson" wrote:

Thank you for your rapid response, Michael.

Unfortunately, I'm doing this as a favor for a friend, and am not able to
drop $200 on Redemption for this project.

I have made some code that will actually link to the url's after being
unable to find answers on the web (I've pasted my code below), but it's very
limited (and, at the moment, requires the original images to be jpg files).
If anyone knows where I can find some more efficient solutions, please let me
know. Here's the code:

Set FSO = CreateObject("Scripting.FileSystemObject")
Set bdy = FSO.OpenTextFile(strFile)
strText = bdy.readall

intSearch = 1
intPicNum = 0
strText = Right(strText, Len(strText) - InStr(1, strText, "body") + 1)
Do While intSearch Len(strText)
If InStr(intSearch, strText, "img") = 0 Then
intSearch = Len(strText)
Else:
intSearch = InStr(intSearch, strText, "img")
intPicNum = intPicNum + 1
MsgBox (InStr(intSearch, strText, "jpg"))
MsgBox (InStr(intSearch + 70, strText, "jpg"))
strText = Left(strText, InStr(intSearch, strText, "src=") + 4) &
InputBox_("Pictures sent through this utility MUST be linked to a picture on
the internet." &_ Chr(13) & "Please enter the FULL web address for picture
no. " &_ intPicNum, "Picture Location") & Right(strText, Len(strText) -
InStr(intSearch,_ strText, "jpg") - 2)
intSearch = intSearch + 4
End If
Loop

Do While IsNull(Me.Email) = False
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = CreateItem(olMailItem)

With objMail
.To = strTo
.Subject = strSubject
.HTMLBody = strText
.Send
End With
DoCmd.GoToRecord , , acNext
Loop


I hope this helps someone who may stumble on this...it's still pretty
limited, though.

"Michael Bauer [MVP - Outlook]" wrote:


Here's a sample, based on a template from Dmitry Streblchenko:
http://www.vboffice.net/sample.html?...9&cmd=showitem

For that sample you need the Redemption (www.dimastr.com).

Call AddEmbeddedAttachment with

- Mail: Outlook MailItem
- File: Full file name of the image file
- [PositionID]: You can insert a placeholder into the e-mails HTMLBody and
pass that placeholder here. The image then would be placed at that position.
If there's no placeholder the image would be inserted at the end.
- [Description]: Optional description for the image


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Keep your Outlook categories organized!
http://www.shareit.com/product.html?...4&languageid=1
(German: http://www.VBOffice.net/product.html?pub=6)


Am Tue, 30 Jan 2007 16:44:00 -0800 schrieb Tim Johnson:

Hi there,

I am working on the development of a database (Access). I think that
because the issues I'm having are outlook related, though, that this is

the
appropriate place for posting this.

I use a VBA sub to create an instance of Outlook by which I send
"personalized" emails. Most of these emails are designed using Word and
include images, then are saved as HTML files. My code is currently:

Set FSO = CreateObject("Scripting.FileSystemObject")
Set bdy = FSO.OpenTextFile(strFile,1)
strText = bdy.readall

With objMail
.To = strTo
.Subject = strSubject
.HTMLBody = strText
.Send
End With

The email's body & formatting come through just fine, but the images are
broken links (it appears from the source as though they're tring to link

to a
local location).

Is there a way to include the images without having to post them on the
internet each time?

Thanks in advance


  #5  
Old January 31st 07, 11:33 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default HTMLBody with images



For private use Redemption is for free. But you could also adapt the code
and work with CDO 1.21 instead of Redemption in this case.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Keep your Outlook categories organized!
http://www.shareit.com/product.html?...4&languageid=1
(German: http://www.VBOffice.net/product.html?pub=6)

Am Wed, 31 Jan 2007 00:15:01 -0800 schrieb Tim Johnson:

Thank you for your rapid response, Michael.

Unfortunately, I'm doing this as a favor for a friend, and am not able to
drop $200 on Redemption for this project.

I have made some code that will actually link to the url's after being
unable to find answers on the web (I've pasted my code below), but it's

very
limited (and, at the moment, requires the original images to be jpg

files).
If anyone knows where I can find some more efficient solutions, please let

me
know. Here's the code:

Set FSO = CreateObject("Scripting.FileSystemObject")
Set bdy = FSO.OpenTextFile(strFile)
strText = bdy.readall

intSearch = 1
intPicNum = 0
strText = Right(strText, Len(strText) - InStr(1, strText, "body") + 1)
Do While intSearch Len(strText)
If InStr(intSearch, strText, "img") = 0 Then
intSearch = Len(strText)
Else:
intSearch = InStr(intSearch, strText, "img")
intPicNum = intPicNum + 1
MsgBox (InStr(intSearch, strText, "jpg"))
MsgBox (InStr(intSearch + 70, strText, "jpg"))
strText = Left(strText, InStr(intSearch, strText, "src=") + 4) &
InputBox_("Pictures sent through this utility MUST be linked to a picture

on
the internet." &_ Chr(13) & "Please enter the FULL web address for picture
no. " &_ intPicNum, "Picture Location") & Right(strText, Len(strText) -
InStr(intSearch,_ strText, "jpg") - 2)
intSearch = intSearch + 4
End If
Loop

Do While IsNull(Me.Email) = False
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = CreateItem(olMailItem)

With objMail
.To = strTo
.Subject = strSubject
.HTMLBody = strText
.Send
End With
DoCmd.GoToRecord , , acNext
Loop


I hope this helps someone who may stumble on this...it's still pretty
limited, though.

"Michael Bauer [MVP - Outlook]" wrote:


Here's a sample, based on a template from Dmitry Streblchenko:
http://www.vboffice.net/sample.html?...9&cmd=showitem

For that sample you need the Redemption (www.dimastr.com).

Call AddEmbeddedAttachment with

- Mail: Outlook MailItem
- File: Full file name of the image file
- [PositionID]: You can insert a placeholder into the e-mails HTMLBody

and
pass that placeholder here. The image then would be placed at that

position.
If there's no placeholder the image would be inserted at the end.
- [Description]: Optional description for the image


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Keep your Outlook categories organized!
http://www.shareit.com/product.html?...4&languageid=1
(German: http://www.VBOffice.net/product.html?pub=6)


Am Tue, 30 Jan 2007 16:44:00 -0800 schrieb Tim Johnson:

Hi there,

I am working on the development of a database (Access). I think that
because the issues I'm having are outlook related, though, that this is

the
appropriate place for posting this.

I use a VBA sub to create an instance of Outlook by which I send
"personalized" emails. Most of these emails are designed using Word and
include images, then are saved as HTML files. My code is currently:

Set FSO = CreateObject("Scripting.FileSystemObject")
Set bdy = FSO.OpenTextFile(strFile,1)
strText = bdy.readall

With objMail
.To = strTo
.Subject = strSubject
.HTMLBody = strText
.Send
End With

The email's body & formatting come through just fine, but the images are
broken links (it appears from the source as though they're tring to link

to a
local location).

Is there a way to include the images without having to post them on the
internet each time?

Thanks in advance


  #6  
Old February 1st 07, 01:30 AM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default HTMLBody with images

For a CDO example, see http://www.outlookcode.com/d/code/htmlimg.htm

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Michael Bauer [MVP - Outlook]" wrote in message .. .


For private use Redemption is for free. But you could also adapt the code
and work with CDO 1.21 instead of Redemption in this case.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Keep your Outlook categories organized!
http://www.shareit.com/product.html?...4&languageid=1
(German: http://www.VBOffice.net/product.html?pub=6)

Am Wed, 31 Jan 2007 00:15:01 -0800 schrieb Tim Johnson:

Thank you for your rapid response, Michael.

Unfortunately, I'm doing this as a favor for a friend, and am not able to
drop $200 on Redemption for this project.

I have made some code that will actually link to the url's after being
unable to find answers on the web (I've pasted my code below), but it's

very
limited (and, at the moment, requires the original images to be jpg

files).
If anyone knows where I can find some more efficient solutions, please let

me
know. Here's the code:

Set FSO = CreateObject("Scripting.FileSystemObject")
Set bdy = FSO.OpenTextFile(strFile)
strText = bdy.readall

intSearch = 1
intPicNum = 0
strText = Right(strText, Len(strText) - InStr(1, strText, "body") + 1)
Do While intSearch Len(strText)
If InStr(intSearch, strText, "img") = 0 Then
intSearch = Len(strText)
Else:
intSearch = InStr(intSearch, strText, "img")
intPicNum = intPicNum + 1
MsgBox (InStr(intSearch, strText, "jpg"))
MsgBox (InStr(intSearch + 70, strText, "jpg"))
strText = Left(strText, InStr(intSearch, strText, "src=") + 4) &
InputBox_("Pictures sent through this utility MUST be linked to a picture

on
the internet." &_ Chr(13) & "Please enter the FULL web address for picture
no. " &_ intPicNum, "Picture Location") & Right(strText, Len(strText) -
InStr(intSearch,_ strText, "jpg") - 2)
intSearch = intSearch + 4
End If
Loop

Do While IsNull(Me.Email) = False
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = CreateItem(olMailItem)

With objMail
.To = strTo
.Subject = strSubject
.HTMLBody = strText
.Send
End With
DoCmd.GoToRecord , , acNext
Loop


I hope this helps someone who may stumble on this...it's still pretty
limited, though.

"Michael Bauer [MVP - Outlook]" wrote:


Here's a sample, based on a template from Dmitry Streblchenko:
http://www.vboffice.net/sample.html?...9&cmd=showitem

For that sample you need the Redemption (www.dimastr.com).

Call AddEmbeddedAttachment with

- Mail: Outlook MailItem
- File: Full file name of the image file
- [PositionID]: You can insert a placeholder into the e-mails HTMLBody

and
pass that placeholder here. The image then would be placed at that

position.
If there's no placeholder the image would be inserted at the end.
- [Description]: Optional description for the image


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Keep your Outlook categories organized!
http://www.shareit.com/product.html?...4&languageid=1
(German: http://www.VBOffice.net/product.html?pub=6)


Am Tue, 30 Jan 2007 16:44:00 -0800 schrieb Tim Johnson:

Hi there,

I am working on the development of a database (Access). I think that
because the issues I'm having are outlook related, though, that this is
the
appropriate place for posting this.

I use a VBA sub to create an instance of Outlook by which I send
"personalized" emails. Most of these emails are designed using Word and
include images, then are saved as HTML files. My code is currently:

Set FSO = CreateObject("Scripting.FileSystemObject")
Set bdy = FSO.OpenTextFile(strFile,1)
strText = bdy.readall

With objMail
.To = strTo
.Subject = strSubject
.HTMLBody = strText
.Send
End With

The email's body & formatting come through just fine, but the images are
broken links (it appears from the source as though they're tring to link
to a
local location).

Is there a way to include the images without having to post them on the
internet each time?

Thanks in advance

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
HTMLBody Property of Outlook MailItem Judy Outlook - Using Forms 1 December 27th 06 02:46 AM
How to set a long HTMLBody mml Outlook and VBA 1 October 28th 06 07:39 PM
HTMLBody Houston Lucifer Outlook and VBA 5 July 17th 06 01:16 PM
Spaces Removed in HTMLBody [email protected] Outlook and VBA 3 June 6th 06 09:02 PM
HTMLBody is hidden when emailing a PDF from IE? Stephen Corey Add-ins for Outlook 6 June 6th 06 03:27 PM


All times are GMT +1. The time now is 08:30 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.