Response to voting option does not include text of original message

  • Thread starter Thread starter Alan Campbell
  • Start date Start date
A

Alan Campbell

Hello,

I have the code below which produces an email based on an Excel
spreadsheet range. Everthing is working fine except the response to my
"V_Approved" selection. When a voucher is approved, I want the
original HTML based message included in the response. When I look at
the message in Outlook, prior to responding, the action item created
indicates the "include original message text" is activated.

Can anybody help explain why this is happening? Thanks in advance for
looking at This.

Alan

Sub Mail_Selection_Outlook_Body()
'Is not working in Office 97
Dim source As Range
Dim dest As Workbook
Dim myshape As Shape
Dim OutApp As Object
Dim OutMail As Object
Dim MyAction
'Dim strName As Object
'Set ObjAction = Item.Actions.Add
Set source = Nothing
On Error Resume Next
Set source =
Range("Print_Form").SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If source Is Nothing Then
MsgBox "The selection is not a range or the sheet is protect"
& _
vbNewLine & "please correct and try again.", vbOKOnly
Exit Sub
End If
Application.ScreenUpdating = False
ActiveSheet.Copy
Set dest = ActiveWorkbook
For Each myshape In dest.Sheets(1).Shapes
myshape.Delete
Next
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
'Set outmail = outapp.item.add.
With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = Range("Vouch_Code") & " Voucher Approval Request -
Acct " & _
Application.text(Range("Acct_1"), "####-###-####") & " - "
& _
Application.text(Range("Voucher_Amount"), "$###.##") & " -
" & Application.text(Right(Range("'Voucher Form.xls'!prepared_by"),
6), "00####")
.HTMLBody = RangetoHTML
'.Send 'or use
.Display
End With
Set MyAction = OutMail.Actions.Add
With MyAction
.CopyLike = olRespond
.Enabled = True
.Prefix = ""
.ReplyStyle = olIncludeOriginalText
.ResponseStyle = olPrompt
.ShowOn = olMenuAndToolbar
.Name = "V_Approved"
End With
Set MyAction = OutMail.Actions.Add
With MyAction
.CopyLike = olRespond
.Enabled = True
.Prefix = ""
.ReplyStyle = olOmitOriginalText
.ResponseStyle = olPrompt
.ShowOn = olMenuAndToolbar
.Name = "V_Rejected"
End With
dest.Close False
Set OutMail = Nothing
Set OutApp = Nothing
Set dest = Nothing
Application.ScreenUpdating = True
End Sub
Function RangetoHTML()
Dim fso As Object
Dim ts As Object
Dim TempFile As String
TempFile = Environ$("temp") & "/" & _
Format(Now, "dd-mm-yy h-mm-ss") & ".htm"
With ActiveWorkbook.PublishObjects.Add( _
SourceType:=xlSourceRange, _
filename:=TempFile, _
Sheet:=ActiveSheet.Name, _
source:=Range("Print_Form").Address, _
HtmlType:=xlHtmlStatic)
.Publish (True)
End With
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(TempFile).OpenAsTextStream(1, -2)
RangetoHTML = ts.ReadAll
ts.Close
Set ts = Nothing
Set fso = Nothing
Kill TempFile
End Function
 
To have the original message text included, you need to have the action set
to display the message before sending. Yes, I know it sounds quirky, but
there is a certain logic to it: The original sender presumably already has
the message and doesn't need to get another copy.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Sue,

Thanks for responding. I did experiment and find the answer after
posting this message. I had the .display option set and that did not
work. I also had the olincludeoriginaltext option set. That
combination did not work.

I ended up using .message = "IPM.Note.Voucher" to the coding for both
voting buttons.

I am only guessing, but I believe this publishes the document as a
unique form and overrides the default message template(?).

I certainly welcome your thoughts on this one.

Alan
 
Do you mean Action.MessageClass, not Message? That sets the form that the
response will use, a form that must already be published.
 
Yes. I meant messageclass. The function used to produce the body
publishes the document (I think?). It appears setting this form name in
the code sets the document up as a new form.
 
"Document"? Outlook doesn't have documents. It has forms (i.e. layout and
code templates) and items (i.e. data records).

Since you haven't quoted the earlier messages in this thread, I'm at a loss
to know what the issue is, or if there even is one remaining.
 
Sue,

You will have to excuse my misuse of terms in the posts. As I mentioned
in my first post, I am not a programmer. The document I referred to is
the Form you mentioned.

I do have a new problem. When sending the form to others, They can not
resond with voting buttons. The message "Form Can Not be Displayed"
appears when either button is selected.

Is there a way to puslish the document on their machine when it is
received and opened?
 
In general, message forms should be published to the Organizational Forms
library in an Exchange environment, along with any response forms used by
the actions on the (Actions) page. Otherwise, each user needs to publish the
forms to their own Personal Forms library, either manually or
programmatically(using the FormDescription.Publish method) before they can
use view any items using those forms. Forms cannot be made self-publishing;
that would be a gross security violation.

See http://www.outlookcode.com/d/distributeforms.htm for more on this issue.
 
Sue,

I have been doing some reading in the google news groups on the issue of
sending form definitions as a substitute to my question on publising a
document when opened.

I would like to be able to programatically set the send form definitions
switch on as part of the coding I included in my earlier post.

I am generating and email, with voting options within Excel. The email,
or form, does not contain any code, scripts etc. that would fail due to
the security patches I have read about.

When the new email is created via Excel, I can open the form design and
change the setting. Once sent, the response is returned with the
original message included; This is my end goal.

I have been unsuccesful in finding any code that helps me to automate
this option as part of the code I have in my Excel spreadsheet. Any
help with this would be appreciated.

Alan
 
The FormDescription.OneOff property apparently is tied to the "Send form
definition with item" check box. Note, however, that one-off forms make the
items much larger, and code won't run. I'm not sure that it will help your
project, but go ahead and try it and let us know how it goes.
 
Back
Top