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

How to integrate company logo with auto send using vb.net



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 6th 06, 03:23 PM posted to microsoft.public.outlook.program_vba
[email protected]
external usenet poster
 
Posts: 4
Default How to integrate company logo with auto send using vb.net

Hi,

In my VB.NET Windows form application, I'm using the Outlook object to
compose and
automatically send email. The spec also requires that I integrate the
company logo on the top of the email to look like the company
letterhead. I tried creating a html page with the company logo design
on it and set
it as the default stationery. It works when I compose a new email
manually from Outlook. But when the email is composed and sent from
VB.NET code using the Outlook MailItem, for reason beyond my level of
understanding, the default stationery is not used. Instead all I see
is a blank template. I'm fairly new at this game. I greatly
appreciate your help.

Ads
  #2  
Old April 6th 06, 05:50 PM posted to microsoft.public.outlook.program_vba
Dave Kane [MVP - Outlook]
external usenet poster
 
Posts: 33
Default How to integrate company logo with auto send using vb.net

Outlook stationery really belongs to the Word editor, and there may be an
easy way to do this through Word automation. I can suggest two different
approaches using Outlook

Option #1: You can set the HTMLBody property of your Outlook.MailItem to
repro the stationery that you created, including whatever formatted text you
want in the email. But if you look at the HTML source for your stationery
you will see that the src property of the IMG tag for the company logo looks
something like src="cid:760521916@20082002-17cb". That cid value corresponds
to the PR_ATTACH_CONTENT_ID (&H3712001E) property of a hidden attachment to
the message that holds the image. So in addition to specifying the HTML
source of the message by setting HTMLBody you would need to add the logo
image as an attachment and set its PR_ATTACH_CONTENT_ID. The Outlook object
model will allow you to add the attachment, but to set any properties on an
attachment you would have to use ExMAPI or a component like Redemption.
That's the most flexible approach since you can easily change the HTML and
the image.

Option #2: Reproduce your stationery template using the Outlook HTML editor,
save it as as an OFT file and then use Outlook's CreateItemFromTemplate
method to create your new MailItem. The HTMLBody property of the new
MailItem will contain the full HTML source for the message, including an IMG
src pointing to the hidden attachment of your logo image. You would need to
read that property, parse it to find where to place your message text and
then reset the value of HTMLBody. The coding is simpler, but you need to
rebuild the OFT file if your logo changes.


wrote in message
oups.com...
Hi,

In my VB.NET Windows form application, I'm using the Outlook object to
compose and
automatically send email. The spec also requires that I integrate the
company logo on the top of the email to look like the company
letterhead. I tried creating a html page with the company logo design
on it and set
it as the default stationery. It works when I compose a new email
manually from Outlook. But when the email is composed and sent from
VB.NET code using the Outlook MailItem, for reason beyond my level of
understanding, the default stationery is not used. Instead all I see
is a blank template. I'm fairly new at this game. I greatly
appreciate your help.



  #3  
Old April 6th 06, 08:03 PM posted to microsoft.public.outlook.program_vba
[email protected]
external usenet poster
 
Posts: 4
Default How to integrate company logo with auto send using vb.net

Hi Dave,

Firstly, thank you for your help. I googled on this topic for the past
day and a half but came up empty. I'm still green in this area so I
would appreciate it very much if you have some code sample for me to
look at -- for Option 1 and/or 2. At least now I know it can be done.
I was ready to give in and tell me boss otherwise. I really, really
appreciate your help!!! Thanks a million.


Dave Kane [MVP - Outlook] wrote:
Outlook stationery really belongs to the Word editor, and there may be an
easy way to do this through Word automation. I can suggest two different
approaches using Outlook

Option #1: You can set the HTMLBody property of your Outlook.MailItem to
repro the stationery that you created, including whatever formatted text you
want in the email. But if you look at the HTML source for your stationery
you will see that the src property of the IMG tag for the company logo looks
something like src="cid:760521916@20082002-17cb". That cid value corresponds
to the PR_ATTACH_CONTENT_ID (&H3712001E) property of a hidden attachment to
the message that holds the image. So in addition to specifying the HTML
source of the message by setting HTMLBody you would need to add the logo
image as an attachment and set its PR_ATTACH_CONTENT_ID. The Outlook object
model will allow you to add the attachment, but to set any properties on an
attachment you would have to use ExMAPI or a component like Redemption.
That's the most flexible approach since you can easily change the HTML and
the image.

Option #2: Reproduce your stationery template using the Outlook HTML editor,
save it as as an OFT file and then use Outlook's CreateItemFromTemplate
method to create your new MailItem. The HTMLBody property of the new
MailItem will contain the full HTML source for the message, including an IMG
src pointing to the hidden attachment of your logo image. You would need to
read that property, parse it to find where to place your message text and
then reset the value of HTMLBody. The coding is simpler, but you need to
rebuild the OFT file if your logo changes.


wrote in message
oups.com...
Hi,

In my VB.NET Windows form application, I'm using the Outlook object to
compose and
automatically send email. The spec also requires that I integrate the
company logo on the top of the email to look like the company
letterhead. I tried creating a html page with the company logo design
on it and set
it as the default stationery. It works when I compose a new email
manually from Outlook. But when the email is composed and sent from
VB.NET code using the Outlook MailItem, for reason beyond my level of
understanding, the default stationery is not used. Instead all I see
is a blank template. I'm fairly new at this game. I greatly
appreciate your help.


  #4  
Old April 6th 06, 10:27 PM posted to microsoft.public.outlook.program_vba
Dave Kane [MVP - Outlook]
external usenet poster
 
Posts: 33
Default How to integrate company logo with auto send using vb.net

Option 2 is less technically challenging, so why not start with that.

Step #1 is creating a template in the Outlook HTML editor:
1. Create a new blank message using your stationery
2. From the main Outlook menu (I'm using Outlook 2003) click Actions New
Mail Message Using Microsoft Office Outlook (HTML)
3. Put your cursor in the body of the stationery message, click Ctrl+A to
select all and then Ctrl+C to copy
4. Put your cursor in the body of the Outlook HTML message and click Ctrl+V
to paste. That won't grab the background image if you have spec'd one - to
add that you will need to use Format Background, etc. from the message
menu
5. Create an Outlook template file (OFT) from the HTML message by clicking
File Save As... and selecting Outlook template (*.oft) as the type. Save
it to a directory that your WinForms application can access

Step #2 is using the template in your code when you create a new item.
Assuming your Outlook application object is mobjOlApp and the template is at
C:\CompanyLogo.oft
Dim myMail as Outlook.MailItem
myMail =
CType(mobjOlApp.CreateItemFromTemplate("C:\Company Logo.oft"),Outlook.MailItem)

myMail.HTMLBody will have the full HTML source for your message, with
HTML, HEAD and BODY tags, etc. You'll need to find the point after the
IMG tag for your logo where you want to insert the text of the message
that you want to send, wherever that may be. Modify the value of HTMLBody so
that it includes your text. Then set the values of Subject, add your
recipient(s) and call Send. Does that get you what you need?

wrote in message
oups.com...
Hi Dave,

Firstly, thank you for your help. I googled on this topic for the past
day and a half but came up empty. I'm still green in this area so I
would appreciate it very much if you have some code sample for me to
look at -- for Option 1 and/or 2. At least now I know it can be done.
I was ready to give in and tell me boss otherwise. I really, really
appreciate your help!!! Thanks a million.


Dave Kane [MVP - Outlook] wrote:
Outlook stationery really belongs to the Word editor, and there may be an
easy way to do this through Word automation. I can suggest two different
approaches using Outlook

Option #1: You can set the HTMLBody property of your Outlook.MailItem to
repro the stationery that you created, including whatever formatted text
you
want in the email. But if you look at the HTML source for your stationery
you will see that the src property of the IMG tag for the company logo
looks
something like src="cid:760521916@20082002-17cb". That cid value
corresponds
to the PR_ATTACH_CONTENT_ID (&H3712001E) property of a hidden attachment
to
the message that holds the image. So in addition to specifying the HTML
source of the message by setting HTMLBody you would need to add the logo
image as an attachment and set its PR_ATTACH_CONTENT_ID. The Outlook
object
model will allow you to add the attachment, but to set any properties on
an
attachment you would have to use ExMAPI or a component like Redemption.
That's the most flexible approach since you can easily change the HTML
and
the image.

Option #2: Reproduce your stationery template using the Outlook HTML
editor,
save it as as an OFT file and then use Outlook's CreateItemFromTemplate
method to create your new MailItem. The HTMLBody property of the new
MailItem will contain the full HTML source for the message, including an
IMG
src pointing to the hidden attachment of your logo image. You would need
to
read that property, parse it to find where to place your message text and
then reset the value of HTMLBody. The coding is simpler, but you need to
rebuild the OFT file if your logo changes.


wrote in message
oups.com...
Hi,

In my VB.NET Windows form application, I'm using the Outlook object to
compose and
automatically send email. The spec also requires that I integrate the
company logo on the top of the email to look like the company
letterhead. I tried creating a html page with the company logo design
on it and set
it as the default stationery. It works when I compose a new email
manually from Outlook. But when the email is composed and sent from
VB.NET code using the Outlook MailItem, for reason beyond my level of
understanding, the default stationery is not used. Instead all I see
is a blank template. I'm fairly new at this game. I greatly
appreciate your help.




  #5  
Old April 7th 06, 12:42 AM posted to microsoft.public.outlook.program_vba
[email protected]
external usenet poster
 
Posts: 4
Default How to integrate company logo with auto send using vb.net

Hi Dave,

I followed your instruction but it did not come out right. Here's my
code:

Dim oApp As Outlook._Application
oApp = New Outlook.Application
Dim oMsg As Outlook._MailItem
oMsg = CType(oApp.CreateItemFromTemplate("C:\BOSLH.oft"),
Outlook.MailItem)
oMsg.Subject = "Testing..."
oMsg.HTMLBody = "Testing..." & vbCrLf & vbCrLf & "Line 4"
oMsg.To = "

The email that came thru did not have the logo as designed. Instead,
it has a blank look to it and the logo is attached with the email. Can
you please give me more instruction on how to carry this out, "You'll
need to find the point after the IMG tag for your logo where you want
to insert the text of the message that you want to send". I noticed
that vbCrLf does not work with HTMLBody. A million thanks to you.

Dave Kane [MVP - Outlook] wrote:
Option 2 is less technically challenging, so why not start with that.

Step #1 is creating a template in the Outlook HTML editor:
1. Create a new blank message using your stationery
2. From the main Outlook menu (I'm using Outlook 2003) click Actions New
Mail Message Using Microsoft Office Outlook (HTML)
3. Put your cursor in the body of the stationery message, click Ctrl+A to
select all and then Ctrl+C to copy
4. Put your cursor in the body of the Outlook HTML message and click Ctrl+V
to paste. That won't grab the background image if you have spec'd one - to
add that you will need to use Format Background, etc. from the message
menu
5. Create an Outlook template file (OFT) from the HTML message by clicking
File Save As... and selecting Outlook template (*.oft) as the type. Save
it to a directory that your WinForms application can access

Step #2 is using the template in your code when you create a new item.
Assuming your Outlook application object is mobjOlApp and the template is at
C:\CompanyLogo.oft
Dim myMail as Outlook.MailItem
myMail =
CType(mobjOlApp.CreateItemFromTemplate("C:\Company Logo.oft"),Outlook.MailItem)

myMail.HTMLBody will have the full HTML source for your message, with
HTML, HEAD and BODY tags, etc. You'll need to find the point after the
IMG tag for your logo where you want to insert the text of the message
that you want to send, wherever that may be. Modify the value of HTMLBody so
that it includes your text. Then set the values of Subject, add your
recipient(s) and call Send. Does that get you what you need?

wrote in message
oups.com...
Hi Dave,

Firstly, thank you for your help. I googled on this topic for the past
day and a half but came up empty. I'm still green in this area so I
would appreciate it very much if you have some code sample for me to
look at -- for Option 1 and/or 2. At least now I know it can be done.
I was ready to give in and tell me boss otherwise. I really, really
appreciate your help!!! Thanks a million.


Dave Kane [MVP - Outlook] wrote:
Outlook stationery really belongs to the Word editor, and there may be an
easy way to do this through Word automation. I can suggest two different
approaches using Outlook

Option #1: You can set the HTMLBody property of your Outlook.MailItem to
repro the stationery that you created, including whatever formatted text
you
want in the email. But if you look at the HTML source for your stationery
you will see that the src property of the IMG tag for the company logo
looks
something like src="cid:760521916@20082002-17cb". That cid value
corresponds
to the PR_ATTACH_CONTENT_ID (&H3712001E) property of a hidden attachment
to
the message that holds the image. So in addition to specifying the HTML
source of the message by setting HTMLBody you would need to add the logo
image as an attachment and set its PR_ATTACH_CONTENT_ID. The Outlook
object
model will allow you to add the attachment, but to set any properties on
an
attachment you would have to use ExMAPI or a component like Redemption.
That's the most flexible approach since you can easily change the HTML
and
the image.

Option #2: Reproduce your stationery template using the Outlook HTML
editor,
save it as as an OFT file and then use Outlook's CreateItemFromTemplate
method to create your new MailItem. The HTMLBody property of the new
MailItem will contain the full HTML source for the message, including an
IMG
src pointing to the hidden attachment of your logo image. You would need
to
read that property, parse it to find where to place your message text and
then reset the value of HTMLBody. The coding is simpler, but you need to
rebuild the OFT file if your logo changes.


wrote in message
oups.com...
Hi,

In my VB.NET Windows form application, I'm using the Outlook object to
compose and
automatically send email. The spec also requires that I integrate the
company logo on the top of the email to look like the company
letterhead. I tried creating a html page with the company logo design
on it and set
it as the default stationery. It works when I compose a new email
manually from Outlook. But when the email is composed and sent from
VB.NET code using the Outlook MailItem, for reason beyond my level of
understanding, the default stationery is not used. Instead all I see
is a blank template. I'm fairly new at this game. I greatly
appreciate your help.



  #6  
Old April 7th 06, 05:26 PM posted to microsoft.public.outlook.program_vba
Dave Kane [MVP - Outlook]
external usenet poster
 
Posts: 33
Default How to integrate company logo with auto send using vb.net

Jonathan,

I assumed that you had some familiarity with HTML. Unfortunately you are
going to need to get at least a little bit to make this work.

The HTMLBody property of your message contains ALL the HTML for your
template. If you open a web page in a browser, right-click and select View
Source you will see a bunch of stuff that looks something like this (where
"..." indicates sections that have been left out):

html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns="urn:schemas-microsoft-comfficeffice"
xmlns:w="urn:schemas-microsoft-comffice:word"
xmlns="http://www.w3.org/TR/REC-html40"
head
...
/head

body lang=EN-US link=blue vlink=purple style='tab-interval:.5in'

p class=MsoNormal align=center style='text-align:center'font size=3
color=black face=Arialspan style='font-size:12.0pt;font-family:Arial;
color:black'img width=600 height=60 id="_x0000_i1025"
src="cid:155132615@06042006-0998" align=bottom
u1:shapes="ridImg"/span/font/p

/body

/html

This is the HTML for a simple page with one image, like you are trying to
create. The IMG tag specifies what picture to show, where the image is
positioned in the HTML, etc.:
img width=600 height=60 id="_x0000_i1025"
src="cid:155132615@06042006-0998" align=bottom u1:shapes="ridImg"
The SRC property (src="cid:155...") says what file to use for the image,
which in this case is a hidden attachment.

The image is inside of a paragraph (defined by the "open paragaraph" p ...
and "close paragraph" /p tags.
If the image is supposed to be at the top and I want to add some text after
that I would add paragraphs after the image paragraph but before the end of
the body, which is denoted by the "close body" tag /body
Add this:
pTesting.../p
p/p
p/p
pLine 4/p
Before this: /body

It won't work to all the HTML with a line of text, which is what your code
does - you have to preserve the existing HTML and add to it. A simple way to
do that is to use the Replace method to add your HTML ahead of "/body"
message text, including close body tag
Dim strText as String = "pTesting.../pp/pp/ppLine
4/p/body"
Dim strHTML as String = oMsg.HTMLBody
'use Replace to add message text in the body
oMsg.HTMLBody = Replace(strHTML,"/body", strText)

You can format your message text anyway you like, but you'll need to learn
some HTML to do that

wrote in message
ups.com...
Hi Dave,

I followed your instruction but it did not come out right. Here's my
code:

Dim oApp As Outlook._Application
oApp = New Outlook.Application
Dim oMsg As Outlook._MailItem
oMsg = CType(oApp.CreateItemFromTemplate("C:\BOSLH.oft"),
Outlook.MailItem)
oMsg.Subject = "Testing..."
oMsg.HTMLBody = "Testing..." & vbCrLf & vbCrLf & "Line 4"
oMsg.To = "

The email that came thru did not have the logo as designed. Instead,
it has a blank look to it and the logo is attached with the email. Can
you please give me more instruction on how to carry this out, "You'll
need to find the point after the IMG tag for your logo where you want
to insert the text of the message that you want to send". I noticed
that vbCrLf does not work with HTMLBody. A million thanks to you.

Dave Kane [MVP - Outlook] wrote:
Option 2 is less technically challenging, so why not start with that.

Step #1 is creating a template in the Outlook HTML editor:
1. Create a new blank message using your stationery
2. From the main Outlook menu (I'm using Outlook 2003) click Actions
New
Mail Message Using Microsoft Office Outlook (HTML)
3. Put your cursor in the body of the stationery message, click Ctrl+A to
select all and then Ctrl+C to copy
4. Put your cursor in the body of the Outlook HTML message and click
Ctrl+V
to paste. That won't grab the background image if you have spec'd one -
to
add that you will need to use Format Background, etc. from the message
menu
5. Create an Outlook template file (OFT) from the HTML message by
clicking
File Save As... and selecting Outlook template (*.oft) as the type.
Save
it to a directory that your WinForms application can access

Step #2 is using the template in your code when you create a new item.
Assuming your Outlook application object is mobjOlApp and the template is
at
C:\CompanyLogo.oft
Dim myMail as Outlook.MailItem
myMail =
CType(mobjOlApp.CreateItemFromTemplate("C:\Company Logo.oft"),Outlook.MailItem)

myMail.HTMLBody will have the full HTML source for your message, with
HTML, HEAD and BODY tags, etc. You'll need to find the point after
the
IMG tag for your logo where you want to insert the text of the message
that you want to send, wherever that may be. Modify the value of HTMLBody
so
that it includes your text. Then set the values of Subject, add your
recipient(s) and call Send. Does that get you what you need?

wrote in message
oups.com...
Hi Dave,

Firstly, thank you for your help. I googled on this topic for the past
day and a half but came up empty. I'm still green in this area so I
would appreciate it very much if you have some code sample for me to
look at -- for Option 1 and/or 2. At least now I know it can be done.
I was ready to give in and tell me boss otherwise. I really, really
appreciate your help!!! Thanks a million.


Dave Kane [MVP - Outlook] wrote:
Outlook stationery really belongs to the Word editor, and there may be
an
easy way to do this through Word automation. I can suggest two
different
approaches using Outlook

Option #1: You can set the HTMLBody property of your Outlook.MailItem
to
repro the stationery that you created, including whatever formatted
text
you
want in the email. But if you look at the HTML source for your
stationery
you will see that the src property of the IMG tag for the company logo
looks
something like src="cid:760521916@20082002-17cb". That cid value
corresponds
to the PR_ATTACH_CONTENT_ID (&H3712001E) property of a hidden
attachment
to
the message that holds the image. So in addition to specifying the
HTML
source of the message by setting HTMLBody you would need to add the
logo
image as an attachment and set its PR_ATTACH_CONTENT_ID. The Outlook
object
model will allow you to add the attachment, but to set any properties
on
an
attachment you would have to use ExMAPI or a component like
Redemption.
That's the most flexible approach since you can easily change the HTML
and
the image.

Option #2: Reproduce your stationery template using the Outlook HTML
editor,
save it as as an OFT file and then use Outlook's
CreateItemFromTemplate
method to create your new MailItem. The HTMLBody property of the new
MailItem will contain the full HTML source for the message, including
an
IMG
src pointing to the hidden attachment of your logo image. You would
need
to
read that property, parse it to find where to place your message text
and
then reset the value of HTMLBody. The coding is simpler, but you need
to
rebuild the OFT file if your logo changes.


wrote in message
oups.com...
Hi,

In my VB.NET Windows form application, I'm using the Outlook object
to
compose and
automatically send email. The spec also requires that I integrate
the
company logo on the top of the email to look like the company
letterhead. I tried creating a html page with the company logo
design
on it and set
it as the default stationery. It works when I compose a new email
manually from Outlook. But when the email is composed and sent from
VB.NET code using the Outlook MailItem, for reason beyond my level
of
understanding, the default stationery is not used. Instead all I
see
is a blank template. I'm fairly new at this game. I greatly
appreciate your help.





 




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
Contacts by Company: get two separate sets of Company (none) RAMcKellin Outlook - Using Contacts 10 April 30th 09 06:43 PM
Integrate company letterhead in outlook mail using vb.net Newbie Outlook - Using Forms 2 April 5th 06 11:24 PM
How do I insert a company logo when designing a form in Outlook? RobynH Outlook - Using Forms 1 March 29th 06 05:58 AM
need to send rtf format using smtp and vb6 or vb.net aharbour Outlook and VBA 1 February 21st 06 02:56 PM
OL won't auto send/receive LT Outlook - General Queries 3 January 9th 06 01:13 AM


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


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