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

Tags: , , , ,

Insert 'Standard Text' to a reply message





 
 
Thread Tools Display Modes
  #1  
Old July 31st 07, 01:58 PM posted to microsoft.public.outlook.program_vba
OU_MartynF
external usenet poster
 
Posts: 3
Default Insert 'Standard Text' to a reply message

I am trying to insert a block of standard text into a reply message.

Basically when I receive a message I would like to be able to click on reply
and then run a macro that will insert a standard block of text. I have found
some code that nearly works but instead of replying to the original message
it creates a new email to the sender and retains the subject field. It does
however insert the standard text.

It it possible to retain the original message text somehow ?

I am using Outllook 2003 and this is my code

Sub InsertText()
Dim objApp As Outlook.Application
Dim objMsg As Outlook.MailItem
On Error Resume Next

Set objApp = CreateObject("Outlook.Application")
Set objMsg = objApp.ActiveInspector.CurrentItem.Reply

With objMsg
.BodyFormat = olFormatHTML
.HTMLBody = "pStandard text block here/p"
End With

objMsg.Display

Set objMsg = Nothing
Set objApp = Nothing
End Sub


Thanks in advance.

Martyn
Ads
  #2  
Old July 31st 07, 03:59 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,560
Default Insert 'Standard Text' to a reply message

Try using more complete HTML:

.HTMLBody = "htmlbodypStandard text block here/p/body/html"

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"OU_MartynF" wrote in message news
I am trying to insert a block of standard text into a reply message.

Basically when I receive a message I would like to be able to click on reply
and then run a macro that will insert a standard block of text. I have found
some code that nearly works but instead of replying to the original message
it creates a new email to the sender and retains the subject field. It does
however insert the standard text.

It it possible to retain the original message text somehow ?

I am using Outllook 2003 and this is my code

Sub InsertText()
Dim objApp As Outlook.Application
Dim objMsg As Outlook.MailItem
On Error Resume Next

Set objApp = CreateObject("Outlook.Application")
Set objMsg = objApp.ActiveInspector.CurrentItem.Reply

With objMsg
.BodyFormat = olFormatHTML
.HTMLBody = "pStandard text block here/p"
End With

objMsg.Display

Set objMsg = Nothing
Set objApp = Nothing
End Sub


Thanks in advance.

Martyn

  #3  
Old July 31st 07, 04:10 PM posted to microsoft.public.outlook.program_vba
OU_MartynF
external usenet poster
 
Posts: 3
Default Insert 'Standard Text' to a reply message

Thanks Sue but it is still firing up a new message rather than including the
original message text below.

Regards

Martyn

"Sue Mosher [MVP-Outlook]" wrote:

Try using more complete HTML:

.HTMLBody = "htmlbodypStandard text block here/p/body/html"

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"OU_MartynF" wrote in message news
I am trying to insert a block of standard text into a reply message.

Basically when I receive a message I would like to be able to click on reply
and then run a macro that will insert a standard block of text. I have found
some code that nearly works but instead of replying to the original message
it creates a new email to the sender and retains the subject field. It does
however insert the standard text.

It it possible to retain the original message text somehow ?

I am using Outllook 2003 and this is my code

Sub InsertText()
Dim objApp As Outlook.Application
Dim objMsg As Outlook.MailItem
On Error Resume Next

Set objApp = CreateObject("Outlook.Application")
Set objMsg = objApp.ActiveInspector.CurrentItem.Reply

With objMsg
.BodyFormat = olFormatHTML
.HTMLBody = "pStandard text block here/p"
End With

objMsg.Display

Set objMsg = Nothing
Set objApp = Nothing
End Sub


Thanks in advance.

Martyn


  #4  
Old July 31st 07, 08:56 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,560
Default Insert 'Standard Text' to a reply message

That's what I thought you wanted, since your original code replaced HTMLBody. In other words, Outlook is doing exactly what you're telling it to do -- creating a new reply and replacing the normal reply text with the text you specific. If instead you want to insert your text into the body, you'll need to parse the HTMLBody property of the reply item and insert your text where you want it to appear, e.g. after the body tag (which may have attributes).

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"OU_MartynF" wrote in message ...
Thanks Sue but it is still firing up a new message rather than including the
original message text below.

Regards

Martyn

"Sue Mosher [MVP-Outlook]" wrote:

Try using more complete HTML:

.HTMLBody = "htmlbodypStandard text block here/p/body/html"

"OU_MartynF" wrote in message news
I am trying to insert a block of standard text into a reply message.

Basically when I receive a message I would like to be able to click on reply
and then run a macro that will insert a standard block of text. I have found
some code that nearly works but instead of replying to the original message
it creates a new email to the sender and retains the subject field. It does
however insert the standard text.

It it possible to retain the original message text somehow ?

I am using Outllook 2003 and this is my code

Sub InsertText()
Dim objApp As Outlook.Application
Dim objMsg As Outlook.MailItem
On Error Resume Next

Set objApp = CreateObject("Outlook.Application")
Set objMsg = objApp.ActiveInspector.CurrentItem.Reply

With objMsg
.BodyFormat = olFormatHTML
.HTMLBody = "pStandard text block here/p"
End With

objMsg.Display

Set objMsg = Nothing
Set objApp = Nothing
End Sub


Thanks in advance.

Martyn


  #5  
Old August 1st 07, 09:04 AM posted to microsoft.public.outlook.program_vba
OU_MartynF
external usenet poster
 
Posts: 3
Default Insert 'Standard Text' to a reply message

Sorry Sue, I think I'm out of my depth here. I'm not experienced with coding
as you have probably guessed. Are you able to suggest some code that would
do this ?

Regards

Martyn


"Sue Mosher [MVP-Outlook]" wrote:

That's what I thought you wanted, since your original code replaced HTMLBody. In other words, Outlook is doing exactly what you're telling it to do -- creating a new reply and replacing the normal reply text with the text you specific. If instead you want to insert your text into the body, you'll need to parse the HTMLBody property of the reply item and insert your text where you want it to appear, e.g. after the body tag (which may have attributes).

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"OU_MartynF" wrote in message ...
Thanks Sue but it is still firing up a new message rather than including the
original message text below.

Regards

Martyn

"Sue Mosher [MVP-Outlook]" wrote:

Try using more complete HTML:

.HTMLBody = "htmlbodypStandard text block here/p/body/html"

"OU_MartynF" wrote in message news I am trying to insert a block of standard text into a reply message.

Basically when I receive a message I would like to be able to click on reply
and then run a macro that will insert a standard block of text. I have found
some code that nearly works but instead of replying to the original message
it creates a new email to the sender and retains the subject field. It does
however insert the standard text.

It it possible to retain the original message text somehow ?

I am using Outllook 2003 and this is my code

Sub InsertText()
Dim objApp As Outlook.Application
Dim objMsg As Outlook.MailItem
On Error Resume Next

Set objApp = CreateObject("Outlook.Application")
Set objMsg = objApp.ActiveInspector.CurrentItem.Reply

With objMsg
.BodyFormat = olFormatHTML
.HTMLBody = "pStandard text block here/p"
End With

objMsg.Display

Set objMsg = Nothing
Set objApp = Nothing
End Sub


Thanks in advance.

Martyn


  #6  
Old August 1st 07, 02:15 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,560
Default Insert 'Standard Text' to a reply message

This is about the simplest code I can come up:

strText = "pStandard text block here/p"
strHTML = objMsg.HTMLBody
intBodyStart = Instr(1, strHTML, "body", vbTextCompare)
intBodyEnd = Instr(intBodyStart, strHTML, "")
objMsg.HTMLBody = "htmlbody" & strText & _
Mid(strHTML, intBodyEnd + 1)

It parses the HTMLBody into two strings -- the body tag and what comes after the body tag -- and then concatenates those two strings with the inserted text in the middle.

I would strongly recommend that if you don't have a basic understanding of HTML coding, run don't walk to a basic HTML tutorial.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"OU_MartynF" wrote in message ...
Sorry Sue, I think I'm out of my depth here. I'm not experienced with coding
as you have probably guessed. Are you able to suggest some code that would
do this ?

Regards

Martyn


"Sue Mosher [MVP-Outlook]" wrote:

That's what I thought you wanted, since your original code replaced HTMLBody. In other words, Outlook is doing exactly what you're telling it to do -- creating a new reply and replacing the normal reply text with the text you specific. If instead you want to insert your text into the body, you'll need to parse the HTMLBody property of the reply item and insert your text where you want it to appear, e.g. after the body tag (which may have attributes).

"OU_MartynF" wrote in message ...
Thanks Sue but it is still firing up a new message rather than including the
original message text below.

Regards

Martyn

"Sue Mosher [MVP-Outlook]" wrote:

Try using more complete HTML:

.HTMLBody = "htmlbodypStandard text block here/p/body/html"

"OU_MartynF" wrote in message news I am trying to insert a block of standard text into a reply message.

Basically when I receive a message I would like to be able to click on reply
and then run a macro that will insert a standard block of text. I have found
some code that nearly works but instead of replying to the original message
it creates a new email to the sender and retains the subject field. It does
however insert the standard text.

It it possible to retain the original message text somehow ?

I am using Outllook 2003 and this is my code

Sub InsertText()
Dim objApp As Outlook.Application
Dim objMsg As Outlook.MailItem
On Error Resume Next

Set objApp = CreateObject("Outlook.Application")
Set objMsg = objApp.ActiveInspector.CurrentItem.Reply

With objMsg
.BodyFormat = olFormatHTML
.HTMLBody = "pStandard text block here/p"
End With

objMsg.Display

Set objMsg = Nothing
Set objApp = Nothing
End Sub


Thanks in advance.

Martyn


 




Thread Tools
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
Rule to auto reply using a dynamic text file as attachment or message body DF Outlook - General Queries 0 June 29th 07 06:38 PM
using signature to insert a standard letter ppieri Outlook - General Queries 5 May 6th 07 08:19 PM
Automatically insert the name of the sender in a reply message brianlong@cox.net Outlook - General Queries 0 November 28th 06 04:53 PM
Reply changes text in email message pd Outlook - General Queries 0 October 2nd 06 08:01 PM
insert as text (to insert html into email body) Iona Outlook - General Queries 1 July 13th 06 12:10 PM


All times are GMT +1. The time now is 03:00 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2008 Outlook Banter, part of the NewsgroupBanter project.
The comments are property of their posters.
Pay Day Loans - Personal Loans - Personal Loans - MPAA - Finance