Voting Button

G

Guest

I have created a custom form and am using VBScript to manipulate the objects
on the form. The form has voting buttons added to it automatically but what I
am having difficulty with is dynamically setting the 'Have replies sent to
option'. I would like responses sent to the originator and also to another
fixed address. Can someone please provide me with some sample VBScript code
that I could use to accomplish this task?

Thanks
 
H

Hollis Paul [MVP - Outlook]

. Can someone please provide me with some sample VBScript code
that I could use to accomplish this task?
Go to http://www.outlookcode.com/ and do a search on recipients. That
will give you a list of relevant entries for adding a recipient, and
then a list of relevant code samples.
 
G

Guest

Hi Paul,

I searched the site that you recommended but could not find anything that
referred directly to the option I am trying to set.

Within 'Message Options' there is a 'Have replies sent to:' checkbox, what I
want to do is to programatically check this option and to populate its field
with the two addresses.

Apologies if I have missed something obvious.


Regards
 
H

Hollis Paul [MVP - Outlook]

I searched the site that you recommended but could not find anything that
referred directly to the option I am trying to set.

Within 'Message Options' there is a 'Have replies sent to:' checkbox, what I
want to do is to programatically check this option and to populate its field
with the two addresses.
I am not sure that you really want to worry about the have replies sent to
field. If you want a message to go to two destinations, you add two recipient
objects, with the email and other parameters defined within the recipient
object, to the recipients collection. Then send the message object.

Now, is your code intervening in the message after the vote has been cast?
Then just add the recipients and let it send. If you are intervening when the
original message is being sent, then add the two email addresses as text,
separated by commas, to the replies sent to field. But, doing that relies upon
the functions included in the coding for the voting action. You should look at
that.

As I recall, there is a type field in the recipient object. Check to see if a
reply-to type is defined. If it is, then just adding two objects of reply-to
type is probably the easiest way to go.

There are a lot of possibilities, depending on where in the message generation
cycle you are intervening, so perhaps you should specify that and see if it
simplifies things.
 
G

Guest

Hi Paul,

Sorry but I'm still confused. Here is the code I currently have in my form:

Public strFile

Function Item_Send()

Dim strVersion

Set cmbType = _
Item.GetInspector.ModifiedFormPages.Item("Message").Controls("cmbType")
Set txtVersion = _
Item.GetInspector.ModifiedFormPages.Item("Message").Controls("txtVersion")
strVersion = txtVersion.Value
[Subject] = "Document " & cmbType.Value & " - " & strFile & " v" & strVersion

End Function

Sub cmdBrowseFile_Click()

Dim strFilePath
Dim fso, f
Dim strOrigBody

Set objDialog = CreateObject("UserAccounts.CommonDialog")

objDialog.Filter = "All Files|*.xls;*.doc"
objDialog.InitialDir = "Y:\Comshare\Procedures and Guides\Review\"
intResult = objDialog.ShowOpen

If intResult <> 0 Then
strFilePath = "<file://" & objDialog.FileName & ">"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(objDialog.FileName)
strFile = f.Name
strOrigBody = [Body]
[Body] = strFilePath & vbNewLine & _
vbNewLine & strOrigBody
End If

End Sub

I do not have any 'Have replies sent to' controls on the form. I did add one
and typed in an e-mail address but how would I be able to specify the
sender's e-mail address given that I don't know who the particular user is. I
looked at SenderEMailAddress but couldn't work out how to add this value to
the control.

Thanks for your patience!

Regards
 
H

Hollis Paul [MVP - Outlook]

I do not have any 'Have replies sent to' controls on the form. I did add one
and typed in an e-mail address but how would I be able to specify the
sender's e-mail address given that I don't know who the particular user is.
If you look at the fields in the recipient object, using the Object Explorer
(?) In the script editor, you will find that each recipient object has a type
field. Here is how it is defined:

MailItem recipient: one of the following OlMailRecipientType constants: olBCC,
olCC, olOriginator, or olTo.

So, all you need to do is loop through the recipient objects until you find the
one whose Type field is set to olOriginator. Then pick off the address field
and add it to your string. Remember: VBScript still does not automatically
assign values to constant, so you need to look in the olMailRecipientType to
get the value for olOriginator.
 
H

Hollis Paul [MVP - Outlook]

Function Item_Send()

Dim strVersion

Set cmbType = _
Item.GetInspector.ModifiedFormPages.Item("Message").Controls("cmbType")
Set txtVersion = _
Item.GetInspector.ModifiedFormPages.Item("Message").Controls("txtVersion")
strVersion = txtVersion.Value
[Subject] = "Document " & cmbType.Value & " - " & strFile & " v" & strVersion

End Function
OK, it would appear that you are expecting your code to run after the receiver
has voted and is sending the reply back. In this case you want to add the
recipient object of type olOriginator back as a new recipient object and change
the type to olTo (see my other message for details). Then add a second
recipient object of type olTo with the fixed address that you want to use. Then
do a resolve as shown in this reply by Ken Slovak, except change the resolve to
ResolveAll.

***************************************
From: "Ken Slovak - [MVP - Outlook]" <[email protected]>
Subject: Re: Item.Recipients.Add Not Working for me
Date: Wed, 26 Apr 2006 09:54:12 -0400
Newsgroups: microsoft.public.outlook.program_forms


Does it work better if you instantiate a Recipient object and then resolve
it?

Set oRecip = Item.Recipients.Add("(e-mail address removed)")
oRecip.Resolve


****************************************

Tip to the wise. The code line

Set oRecip = Item.Recipients.Add("(e-mail address removed)")

creates a default recipient object. You want to use an explicit process:

dim omyRecipient
dim olTo = 0 '(or whatever it is)
set myoRecipient = Item.Recipients.Add
omyRecipient.Address = "(e-mail address removed)"
omyRecipient.Type = olTo

Another word to the wise. If you are going to be doing a significant amount of
Outlook forms design and programming, go to www.dimastr.com and buy a copy of
OutlookSpy and Outlook Redemption. It will save you a huge amount of trouble in
the future.
 
G

Guest

Hi Paul,

I think I must be doing something completely wrong! I've added the following
code to try and capture the voting button event:

Function Item_CustomAction(ByVal Action, ByVal NewItem)

Msgbox Action.Name

End Function

But this does not fire, all I get is the default 'Do you want to edit the
message before sending' prompt. I am trying to capture the event so that I
can test adding the recipients. When I publish the form all of the other code
works just not the Msgbox.

Any ideas?

Thanks
David

Hollis Paul said:
Function Item_Send()

Dim strVersion

Set cmbType = _
Item.GetInspector.ModifiedFormPages.Item("Message").Controls("cmbType")
Set txtVersion = _
Item.GetInspector.ModifiedFormPages.Item("Message").Controls("txtVersion")
strVersion = txtVersion.Value
[Subject] = "Document " & cmbType.Value & " - " & strFile & " v" & strVersion

End Function
OK, it would appear that you are expecting your code to run after the receiver
has voted and is sending the reply back. In this case you want to add the
recipient object of type olOriginator back as a new recipient object and change
the type to olTo (see my other message for details). Then add a second
recipient object of type olTo with the fixed address that you want to use. Then
do a resolve as shown in this reply by Ken Slovak, except change the resolve to
ResolveAll.

***************************************
From: "Ken Slovak - [MVP - Outlook]" <[email protected]>
Subject: Re: Item.Recipients.Add Not Working for me
Date: Wed, 26 Apr 2006 09:54:12 -0400
Newsgroups: microsoft.public.outlook.program_forms


Does it work better if you instantiate a Recipient object and then resolve
it?

Set oRecip = Item.Recipients.Add("(e-mail address removed)")
oRecip.Resolve


****************************************

Tip to the wise. The code line

Set oRecip = Item.Recipients.Add("(e-mail address removed)")

creates a default recipient object. You want to use an explicit process:

dim omyRecipient
dim olTo = 0 '(or whatever it is)
set myoRecipient = Item.Recipients.Add
omyRecipient.Address = "(e-mail address removed)"
omyRecipient.Type = olTo

Another word to the wise. If you are going to be doing a significant amount of
Outlook forms design and programming, go to www.dimastr.com and buy a copy of
OutlookSpy and Outlook Redemption. It will save you a huge amount of trouble in
the future.
 
H

Hollis Paul [MVP - Outlook]

Any ideas?
No. I've never programmed for the voting buttons.

You can do your test by returning False from your Item_send event,
which will prevent the item from sending, and then just go to a button
and run your test code in the button click event.
 
S

Sue Mosher [MVP-Outlook]

You'd need to work with the ReplyRecipients collection, which works just like the main Recipients collection, e.g. to add two recipients:

Item.ReplyRecipients.Add "(e-mail address removed)")
strUserAddress = Application.Session.CurrentUser.Address
If strUserAddress <> "" Then
Item.ReplyRecipients.Add strUserAddress
End If

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
S

Sue Mosher [MVP-Outlook]

Any chance that you have a duplicate event handler declaration? That would confuse matters so that the code below wouldn't run on your published form.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

Hi Sue,

Here is the amended code in my form:

------------------------------------------------------------------------------
Public strFile

Function Item_Send()

Dim strVersion
Dim strUserName

Set cmbType = _
Item.GetInspector.ModifiedFormPages.Item("Message").Controls("cmbType")
Set txtVersion = _
Item.GetInspector.ModifiedFormPages.Item("Message").Controls("txtVersion")
strVersion = txtVersion.Value
[Subject] = "Document " & cmbType.Value & " - " & strFile & " v" & strVersion

Select Case cmbType.Text
Case "Change Request"
Item.VotingOptions = "Reject; Implement Immediately; Schedule
Implementation"
Case else
Item.VotingOptions = "Accept; Reject"
End Select

strUserName = Application.Session.CurrentUser.Name

Item.ReplyRecipients.Add "DMS"
Item.ReplyRecipients.Add strUserName

End Function

Sub cmdBrowseFile_Click()

Dim strFilePath
Dim fso, f
Dim strOrigBody

Set objDialog = CreateObject("UserAccounts.CommonDialog")

objDialog.Filter = "All Files|*.xls;*.doc"
objDialog.InitialDir = "Y:\Comshare\Procedures and Guides\Review\"
intResult = objDialog.ShowOpen

If intResult <> 0 Then
strFilePath = "<file://" & objDialog.FileName & ">"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(objDialog.FileName)
strFile = f.Name
strOrigBody = [Body]
[Body] = strFilePath & vbNewLine & _
vbNewLine & strOrigBody
End If

End Sub

--------------------------------------------------------------------------------------

However, whenever the user clicks on any of the voting buttons the reply is
sent to the originator only and does not include the DMS user.

Thanks
David
 
S

Sue Mosher [MVP-Outlook]

Is this a form published to the Organizational Forms library?

Just curious: If the recipient does a regular reply to the message, rather than choosing a voting button, does it go to both recipients?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


DavidW said:
Hi Sue,

Here is the amended code in my form:

------------------------------------------------------------------------------
Public strFile

Function Item_Send()

Dim strVersion
Dim strUserName

Set cmbType = _
Item.GetInspector.ModifiedFormPages.Item("Message").Controls("cmbType")
Set txtVersion = _
Item.GetInspector.ModifiedFormPages.Item("Message").Controls("txtVersion")
strVersion = txtVersion.Value
[Subject] = "Document " & cmbType.Value & " - " & strFile & " v" & strVersion

Select Case cmbType.Text
Case "Change Request"
Item.VotingOptions = "Reject; Implement Immediately; Schedule
Implementation"
Case else
Item.VotingOptions = "Accept; Reject"
End Select

strUserName = Application.Session.CurrentUser.Name

Item.ReplyRecipients.Add "DMS"
Item.ReplyRecipients.Add strUserName

End Function

Sub cmdBrowseFile_Click()

Dim strFilePath
Dim fso, f
Dim strOrigBody

Set objDialog = CreateObject("UserAccounts.CommonDialog")

objDialog.Filter = "All Files|*.xls;*.doc"
objDialog.InitialDir = "Y:\Comshare\Procedures and Guides\Review\"
intResult = objDialog.ShowOpen

If intResult <> 0 Then
strFilePath = "<file://" & objDialog.FileName & ">"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(objDialog.FileName)
strFile = f.Name
strOrigBody = [Body]
[Body] = strFilePath & vbNewLine & _
vbNewLine & strOrigBody
End If

End Sub

--------------------------------------------------------------------------------------

However, whenever the user clicks on any of the voting buttons the reply is
sent to the originator only and does not include the DMS user.

Thanks
David




Sue Mosher said:
You'd need to work with the ReplyRecipients collection, which works just like the main Recipients collection, e.g. to add two recipients:

Item.ReplyRecipients.Add "(e-mail address removed)")
strUserAddress = Application.Session.CurrentUser.Address
If strUserAddress <> "" Then
Item.ReplyRecipients.Add strUserAddress
End If
 
G

Guest

Hi Sue,

The form is published to my Personal forms library and no, when I simply
reply the DMS user is not added to the recipients list.

Thanks
David

Sue Mosher said:
Is this a form published to the Organizational Forms library?

Just curious: If the recipient does a regular reply to the message, rather than choosing a voting button, does it go to both recipients?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


DavidW said:
Hi Sue,

Here is the amended code in my form:

------------------------------------------------------------------------------
Public strFile

Function Item_Send()

Dim strVersion
Dim strUserName

Set cmbType = _
Item.GetInspector.ModifiedFormPages.Item("Message").Controls("cmbType")
Set txtVersion = _
Item.GetInspector.ModifiedFormPages.Item("Message").Controls("txtVersion")
strVersion = txtVersion.Value
[Subject] = "Document " & cmbType.Value & " - " & strFile & " v" & strVersion

Select Case cmbType.Text
Case "Change Request"
Item.VotingOptions = "Reject; Implement Immediately; Schedule
Implementation"
Case else
Item.VotingOptions = "Accept; Reject"
End Select

strUserName = Application.Session.CurrentUser.Name

Item.ReplyRecipients.Add "DMS"
Item.ReplyRecipients.Add strUserName

End Function

Sub cmdBrowseFile_Click()

Dim strFilePath
Dim fso, f
Dim strOrigBody

Set objDialog = CreateObject("UserAccounts.CommonDialog")

objDialog.Filter = "All Files|*.xls;*.doc"
objDialog.InitialDir = "Y:\Comshare\Procedures and Guides\Review\"
intResult = objDialog.ShowOpen

If intResult <> 0 Then
strFilePath = "<file://" & objDialog.FileName & ">"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(objDialog.FileName)
strFile = f.Name
strOrigBody = [Body]
[Body] = strFilePath & vbNewLine & _
vbNewLine & strOrigBody
End If

End Sub

--------------------------------------------------------------------------------------

However, whenever the user clicks on any of the voting buttons the reply is
sent to the originator only and does not include the DMS user.

Thanks
David




Sue Mosher said:
You'd need to work with the ReplyRecipients collection, which works just like the main Recipients collection, e.g. to add two recipients:

Item.ReplyRecipients.Add "(e-mail address removed)")
strUserAddress = Application.Session.CurrentUser.Address
If strUserAddress <> "" Then
Item.ReplyRecipients.Add strUserAddress
End If

I have created a custom form and am using VBScript to manipulate the objects
on the form. The form has voting buttons added to it automatically but what I
am having difficulty with is dynamically setting the 'Have replies sent to
option'. I would like responses sent to the originator and also to another
fixed address. Can someone please provide me with some sample VBScript code
that I could use to accomplish this task?

Thanks
 
S

Sue Mosher [MVP-Outlook]

If you type DMS into the To box of a message and try to send it, what happens? For best results, you should use the SMTP address or a unique string that points to that mailbox.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


DavidW said:
Hi Sue,

The form is published to my Personal forms library and no, when I simply
reply the DMS user is not added to the recipients list.

Thanks
David

Sue Mosher said:
Is this a form published to the Organizational Forms library?

Just curious: If the recipient does a regular reply to the message, rather than choosing a voting button, does it go to both recipients?

DavidW said:
Hi Sue,

Here is the amended code in my form:

------------------------------------------------------------------------------
Public strFile

Function Item_Send()

Dim strVersion
Dim strUserName

Set cmbType = _
Item.GetInspector.ModifiedFormPages.Item("Message").Controls("cmbType")
Set txtVersion = _
Item.GetInspector.ModifiedFormPages.Item("Message").Controls("txtVersion")
strVersion = txtVersion.Value
[Subject] = "Document " & cmbType.Value & " - " & strFile & " v" & strVersion

Select Case cmbType.Text
Case "Change Request"
Item.VotingOptions = "Reject; Implement Immediately; Schedule
Implementation"
Case else
Item.VotingOptions = "Accept; Reject"
End Select

strUserName = Application.Session.CurrentUser.Name

Item.ReplyRecipients.Add "DMS"
Item.ReplyRecipients.Add strUserName

End Function

Sub cmdBrowseFile_Click()

Dim strFilePath
Dim fso, f
Dim strOrigBody

Set objDialog = CreateObject("UserAccounts.CommonDialog")

objDialog.Filter = "All Files|*.xls;*.doc"
objDialog.InitialDir = "Y:\Comshare\Procedures and Guides\Review\"
intResult = objDialog.ShowOpen

If intResult <> 0 Then
strFilePath = "<file://" & objDialog.FileName & ">"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(objDialog.FileName)
strFile = f.Name
strOrigBody = [Body]
[Body] = strFilePath & vbNewLine & _
vbNewLine & strOrigBody
End If

End Sub

--------------------------------------------------------------------------------------

However, whenever the user clicks on any of the voting buttons the reply is
sent to the originator only and does not include the DMS user.

Thanks
David




:

You'd need to work with the ReplyRecipients collection, which works just like the main Recipients collection, e.g. to add two recipients:

Item.ReplyRecipients.Add "(e-mail address removed)")
strUserAddress = Application.Session.CurrentUser.Address
If strUserAddress <> "" Then
Item.ReplyRecipients.Add strUserAddress
End If

I have created a custom form and am using VBScript to manipulate the objects
on the form. The form has voting buttons added to it automatically but what I
am having difficulty with is dynamically setting the 'Have replies sent to
option'. I would like responses sent to the originator and also to another
fixed address. Can someone please provide me with some sample VBScript code
that I could use to accomplish this task?

Thanks
 
G

Guest

Hi Sue,

When I type in DMS as you suggested, the e-mail is sent to the DMS mailbox.

Regards
David

Sue Mosher said:
If you type DMS into the To box of a message and try to send it, what happens? For best results, you should use the SMTP address or a unique string that points to that mailbox.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


DavidW said:
Hi Sue,

The form is published to my Personal forms library and no, when I simply
reply the DMS user is not added to the recipients list.

Thanks
David

Sue Mosher said:
Is this a form published to the Organizational Forms library?

Just curious: If the recipient does a regular reply to the message, rather than choosing a voting button, does it go to both recipients?

Hi Sue,

Here is the amended code in my form:

------------------------------------------------------------------------------
Public strFile

Function Item_Send()

Dim strVersion
Dim strUserName

Set cmbType = _
Item.GetInspector.ModifiedFormPages.Item("Message").Controls("cmbType")
Set txtVersion = _
Item.GetInspector.ModifiedFormPages.Item("Message").Controls("txtVersion")
strVersion = txtVersion.Value
[Subject] = "Document " & cmbType.Value & " - " & strFile & " v" & strVersion

Select Case cmbType.Text
Case "Change Request"
Item.VotingOptions = "Reject; Implement Immediately; Schedule
Implementation"
Case else
Item.VotingOptions = "Accept; Reject"
End Select

strUserName = Application.Session.CurrentUser.Name

Item.ReplyRecipients.Add "DMS"
Item.ReplyRecipients.Add strUserName

End Function

Sub cmdBrowseFile_Click()

Dim strFilePath
Dim fso, f
Dim strOrigBody

Set objDialog = CreateObject("UserAccounts.CommonDialog")

objDialog.Filter = "All Files|*.xls;*.doc"
objDialog.InitialDir = "Y:\Comshare\Procedures and Guides\Review\"
intResult = objDialog.ShowOpen

If intResult <> 0 Then
strFilePath = "<file://" & objDialog.FileName & ">"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(objDialog.FileName)
strFile = f.Name
strOrigBody = [Body]
[Body] = strFilePath & vbNewLine & _
vbNewLine & strOrigBody
End If

End Sub

--------------------------------------------------------------------------------------

However, whenever the user clicks on any of the voting buttons the reply is
sent to the originator only and does not include the DMS user.

Thanks
David




:

You'd need to work with the ReplyRecipients collection, which works just like the main Recipients collection, e.g. to add two recipients:

Item.ReplyRecipients.Add "(e-mail address removed)")
strUserAddress = Application.Session.CurrentUser.Address
If strUserAddress <> "" Then
Item.ReplyRecipients.Add strUserAddress
End If

I have created a custom form and am using VBScript to manipulate the objects
on the form. The form has voting buttons added to it automatically but what I
am having difficulty with is dynamically setting the 'Have replies sent to
option'. I would like responses sent to the originator and also to another
fixed address. Can someone please provide me with some sample VBScript code
that I could use to accomplish this task?

Thanks
 
S

Sue Mosher [MVP-Outlook]

When you do it manually, are you letting Outlook resolve it or are you choosing an autocomplete entry? If the latter, delete the autocomplete entry and try again.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


DavidW said:
Hi Sue,

When I type in DMS as you suggested, the e-mail is sent to the DMS mailbox.

Regards
David

Sue Mosher said:
If you type DMS into the To box of a message and try to send it, what happens? For best results, you should use the SMTP address or a unique string that points to that mailbox.

DavidW said:
Hi Sue,

The form is published to my Personal forms library and no, when I simply
reply the DMS user is not added to the recipients list.

Thanks
David

:

Is this a form published to the Organizational Forms library?

Just curious: If the recipient does a regular reply to the message, rather than choosing a voting button, does it go to both recipients?
Hi Sue,

Here is the amended code in my form:

------------------------------------------------------------------------------
Public strFile

Function Item_Send()

Dim strVersion
Dim strUserName

Set cmbType = _
Item.GetInspector.ModifiedFormPages.Item("Message").Controls("cmbType")
Set txtVersion = _
Item.GetInspector.ModifiedFormPages.Item("Message").Controls("txtVersion")
strVersion = txtVersion.Value
[Subject] = "Document " & cmbType.Value & " - " & strFile & " v" & strVersion

Select Case cmbType.Text
Case "Change Request"
Item.VotingOptions = "Reject; Implement Immediately; Schedule
Implementation"
Case else
Item.VotingOptions = "Accept; Reject"
End Select

strUserName = Application.Session.CurrentUser.Name

Item.ReplyRecipients.Add "DMS"
Item.ReplyRecipients.Add strUserName

End Function

Sub cmdBrowseFile_Click()

Dim strFilePath
Dim fso, f
Dim strOrigBody

Set objDialog = CreateObject("UserAccounts.CommonDialog")

objDialog.Filter = "All Files|*.xls;*.doc"
objDialog.InitialDir = "Y:\Comshare\Procedures and Guides\Review\"
intResult = objDialog.ShowOpen

If intResult <> 0 Then
strFilePath = "<file://" & objDialog.FileName & ">"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(objDialog.FileName)
strFile = f.Name
strOrigBody = [Body]
[Body] = strFilePath & vbNewLine & _
vbNewLine & strOrigBody
End If

End Sub

--------------------------------------------------------------------------------------

However, whenever the user clicks on any of the voting buttons the reply is
sent to the originator only and does not include the DMS user.

Thanks
David




:

You'd need to work with the ReplyRecipients collection, which works just like the main Recipients collection, e.g. to add two recipients:

Item.ReplyRecipients.Add "(e-mail address removed)")
strUserAddress = Application.Session.CurrentUser.Address
If strUserAddress <> "" Then
Item.ReplyRecipients.Add strUserAddress
End If

I have created a custom form and am using VBScript to manipulate the objects
on the form. The form has voting buttons added to it automatically but what I
am having difficulty with is dynamically setting the 'Have replies sent to
option'. I would like responses sent to the originator and also to another
fixed address. Can someone please provide me with some sample VBScript code
that I could use to accomplish this task?

Thanks
 
G

Guest

Hi Sue,

I am allowing Outlook to resolve it.


Sue Mosher said:
When you do it manually, are you letting Outlook resolve it or are you choosing an autocomplete entry? If the latter, delete the autocomplete entry and try again.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


DavidW said:
Hi Sue,

When I type in DMS as you suggested, the e-mail is sent to the DMS mailbox.

Regards
David

Sue Mosher said:
If you type DMS into the To box of a message and try to send it, what happens? For best results, you should use the SMTP address or a unique string that points to that mailbox.

Hi Sue,

The form is published to my Personal forms library and no, when I simply
reply the DMS user is not added to the recipients list.

Thanks
David

:

Is this a form published to the Organizational Forms library?

Just curious: If the recipient does a regular reply to the message, rather than choosing a voting button, does it go to both recipients?


Hi Sue,

Here is the amended code in my form:

------------------------------------------------------------------------------
Public strFile

Function Item_Send()

Dim strVersion
Dim strUserName

Set cmbType = _
Item.GetInspector.ModifiedFormPages.Item("Message").Controls("cmbType")
Set txtVersion = _
Item.GetInspector.ModifiedFormPages.Item("Message").Controls("txtVersion")
strVersion = txtVersion.Value
[Subject] = "Document " & cmbType.Value & " - " & strFile & " v" & strVersion

Select Case cmbType.Text
Case "Change Request"
Item.VotingOptions = "Reject; Implement Immediately; Schedule
Implementation"
Case else
Item.VotingOptions = "Accept; Reject"
End Select

strUserName = Application.Session.CurrentUser.Name

Item.ReplyRecipients.Add "DMS"
Item.ReplyRecipients.Add strUserName

End Function

Sub cmdBrowseFile_Click()

Dim strFilePath
Dim fso, f
Dim strOrigBody

Set objDialog = CreateObject("UserAccounts.CommonDialog")

objDialog.Filter = "All Files|*.xls;*.doc"
objDialog.InitialDir = "Y:\Comshare\Procedures and Guides\Review\"
intResult = objDialog.ShowOpen

If intResult <> 0 Then
strFilePath = "<file://" & objDialog.FileName & ">"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(objDialog.FileName)
strFile = f.Name
strOrigBody = [Body]
[Body] = strFilePath & vbNewLine & _
vbNewLine & strOrigBody
End If

End Sub

--------------------------------------------------------------------------------------

However, whenever the user clicks on any of the voting buttons the reply is
sent to the originator only and does not include the DMS user.

Thanks
David




:

You'd need to work with the ReplyRecipients collection, which works just like the main Recipients collection, e.g. to add two recipients:

Item.ReplyRecipients.Add "(e-mail address removed)")
strUserAddress = Application.Session.CurrentUser.Address
If strUserAddress <> "" Then
Item.ReplyRecipients.Add strUserAddress
End If

I have created a custom form and am using VBScript to manipulate the objects
on the form. The form has voting buttons added to it automatically but what I
am having difficulty with is dynamically setting the 'Have replies sent to
option'. I would like responses sent to the originator and also to another
fixed address. Can someone please provide me with some sample VBScript code
that I could use to accomplish this task?

Thanks
 
S

Sue Mosher [MVP-Outlook]

Then I can't explain why it isn't working on a regular reply (leaving aside the voting button issue). A look at the received message with Outlook Spy or MFCMAPI might be revealing.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


DavidW said:
Hi Sue,

I am allowing Outlook to resolve it.


Sue Mosher said:
When you do it manually, are you letting Outlook resolve it or are you choosing an autocomplete entry? If the latter, delete the autocomplete entry and try again.

DavidW said:
Hi Sue,

When I type in DMS as you suggested, the e-mail is sent to the DMS mailbox.

Regards
David

:

If you type DMS into the To box of a message and try to send it, what happens? For best results, you should use the SMTP address or a unique string that points to that mailbox.

Hi Sue,

The form is published to my Personal forms library and no, when I simply
reply the DMS user is not added to the recipients list.

Thanks
David

:

Is this a form published to the Organizational Forms library?

Just curious: If the recipient does a regular reply to the message, rather than choosing a voting button, does it go to both recipients?


Hi Sue,

Here is the amended code in my form:

------------------------------------------------------------------------------
Public strFile

Function Item_Send()

Dim strVersion
Dim strUserName

Set cmbType = _
Item.GetInspector.ModifiedFormPages.Item("Message").Controls("cmbType")
Set txtVersion = _
Item.GetInspector.ModifiedFormPages.Item("Message").Controls("txtVersion")
strVersion = txtVersion.Value
[Subject] = "Document " & cmbType.Value & " - " & strFile & " v" & strVersion

Select Case cmbType.Text
Case "Change Request"
Item.VotingOptions = "Reject; Implement Immediately; Schedule
Implementation"
Case else
Item.VotingOptions = "Accept; Reject"
End Select

strUserName = Application.Session.CurrentUser.Name

Item.ReplyRecipients.Add "DMS"
Item.ReplyRecipients.Add strUserName

End Function

Sub cmdBrowseFile_Click()

Dim strFilePath
Dim fso, f
Dim strOrigBody

Set objDialog = CreateObject("UserAccounts.CommonDialog")

objDialog.Filter = "All Files|*.xls;*.doc"
objDialog.InitialDir = "Y:\Comshare\Procedures and Guides\Review\"
intResult = objDialog.ShowOpen

If intResult <> 0 Then
strFilePath = "<file://" & objDialog.FileName & ">"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(objDialog.FileName)
strFile = f.Name
strOrigBody = [Body]
[Body] = strFilePath & vbNewLine & _
vbNewLine & strOrigBody
End If

End Sub

--------------------------------------------------------------------------------------

However, whenever the user clicks on any of the voting buttons the reply is
sent to the originator only and does not include the DMS user.

Thanks
David




:

You'd need to work with the ReplyRecipients collection, which works just like the main Recipients collection, e.g. to add two recipients:

Item.ReplyRecipients.Add "(e-mail address removed)")
strUserAddress = Application.Session.CurrentUser.Address
If strUserAddress <> "" Then
Item.ReplyRecipients.Add strUserAddress
End If

I have created a custom form and am using VBScript to manipulate the objects
on the form. The form has voting buttons added to it automatically but what I
am having difficulty with is dynamically setting the 'Have replies sent to
option'. I would like responses sent to the originator and also to another
fixed address. Can someone please provide me with some sample VBScript code
that I could use to accomplish this task?

Thanks
 
G

Guest

Hi Sue,

I think we must have crossed wires. To recap, if I create a normal e-mail
and send it to DMS the e-mail is delivered correctly to the DMS mailbox. If I
then access the DMS mailbox and reply to the message the response is
delivered correctly to my mailbox.

With the voting buttons, if I generate an e-mail and add voting buttons and
enter both my mail address and that of the DMS account into the 'Have replies
sent to' field on the Options page, when a voting button is selected the
response is sent to me and to DMS correctly.

The only time that this does not work is if I try to add the recipients
using VBScript.


Regards
David


Sue Mosher said:
Then I can't explain why it isn't working on a regular reply (leaving aside the voting button issue). A look at the received message with Outlook Spy or MFCMAPI might be revealing.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


DavidW said:
Hi Sue,

I am allowing Outlook to resolve it.


Sue Mosher said:
When you do it manually, are you letting Outlook resolve it or are you choosing an autocomplete entry? If the latter, delete the autocomplete entry and try again.

Hi Sue,

When I type in DMS as you suggested, the e-mail is sent to the DMS mailbox.

Regards
David

:

If you type DMS into the To box of a message and try to send it, what happens? For best results, you should use the SMTP address or a unique string that points to that mailbox.

Hi Sue,

The form is published to my Personal forms library and no, when I simply
reply the DMS user is not added to the recipients list.

Thanks
David

:

Is this a form published to the Organizational Forms library?

Just curious: If the recipient does a regular reply to the message, rather than choosing a voting button, does it go to both recipients?


Hi Sue,

Here is the amended code in my form:

------------------------------------------------------------------------------
Public strFile

Function Item_Send()

Dim strVersion
Dim strUserName

Set cmbType = _
Item.GetInspector.ModifiedFormPages.Item("Message").Controls("cmbType")
Set txtVersion = _
Item.GetInspector.ModifiedFormPages.Item("Message").Controls("txtVersion")
strVersion = txtVersion.Value
[Subject] = "Document " & cmbType.Value & " - " & strFile & " v" & strVersion

Select Case cmbType.Text
Case "Change Request"
Item.VotingOptions = "Reject; Implement Immediately; Schedule
Implementation"
Case else
Item.VotingOptions = "Accept; Reject"
End Select

strUserName = Application.Session.CurrentUser.Name

Item.ReplyRecipients.Add "DMS"
Item.ReplyRecipients.Add strUserName

End Function

Sub cmdBrowseFile_Click()

Dim strFilePath
Dim fso, f
Dim strOrigBody

Set objDialog = CreateObject("UserAccounts.CommonDialog")

objDialog.Filter = "All Files|*.xls;*.doc"
objDialog.InitialDir = "Y:\Comshare\Procedures and Guides\Review\"
intResult = objDialog.ShowOpen

If intResult <> 0 Then
strFilePath = "<file://" & objDialog.FileName & ">"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(objDialog.FileName)
strFile = f.Name
strOrigBody = [Body]
[Body] = strFilePath & vbNewLine & _
vbNewLine & strOrigBody
End If

End Sub

--------------------------------------------------------------------------------------

However, whenever the user clicks on any of the voting buttons the reply is
sent to the originator only and does not include the DMS user.

Thanks
David




:

You'd need to work with the ReplyRecipients collection, which works just like the main Recipients collection, e.g. to add two recipients:

Item.ReplyRecipients.Add "(e-mail address removed)")
strUserAddress = Application.Session.CurrentUser.Address
If strUserAddress <> "" Then
Item.ReplyRecipients.Add strUserAddress
End If

I have created a custom form and am using VBScript to manipulate the objects
on the form. The form has voting buttons added to it automatically but what I
am having difficulty with is dynamically setting the 'Have replies sent to
option'. I would like responses sent to the originator and also to another
fixed address. Can someone please provide me with some sample VBScript code
that I could use to accomplish this task?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top