Custom Form, copy user field data to message body

Scalpel4

New Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
#1
I'm betting this has been covered in here, but I'm not finding it. I've done some VB in the past and am pretty good with macros in Excel and Word, but this one's a little more interesting.

I've got a form I built for help desk with 6 custom fields. I'd like to copy any data entered into the fields to the message body upon hitting send. I've built the form and the fields on page 2, then set the address value in the to field, now I just need to get the data to populate the message body like this example:

Issue:
DATA FROM CUSTOM FIELD 1

Description:
DATA FROM CUSTOM FIELD 2

Steps Taken:

DATA FROM CUSTOM FIELD 3
 

Scalpel4

New Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
#2
Just to show I'm not trying to get someone else to write this for me, this is what I've tried without success. I added this code to the send routine which didn't work.

Code:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Function Item_Send()
Body = ""
Body = Body & "Description"&
UserProperties.Find("Description").Value & vbcr
Body = Body & "Preconditions"&
UserProperties.Find("Preconditions").Value & vbcr
Body = Body & "Steps to Recreate"&
UserProperties.Find("Recreate").Value & vbcr
Body = Body & "Actual Results"&
UserProperties.Find("Results").Value & vbcr
Body = Body & "What was expected"&
UserProperties.Find("Expected").Value & vbcr
Body = Body & "Additional Info"&
UserProperties.Find("ExtraInfo").Value & vbcr
End Function
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
#3
Shoot, I meant to test this yesterday but got sidetracked. Can you zip up the form and upload it so I dont have to rebuild it? It will save me some time.
I would probably do a before send, but would need to test it to see if it works.
 

Scalpel4

New Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
#4
Shoot, I meant to test this yesterday but got sidetracked. Can you zip up the form and upload it so I dont have to rebuild it? It will save me some time.
I would probably do a before send, but would need to test it to see if it works.
Thanks! I stripped out the code above because I couldn't get it going.
 

Attachments

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
#6
Ok... I think it is working now...
You need to set these keys per the article I linked earlier.
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\16.0\Outlook\Forms\TrustedFormScriptList]
"IPM.Note"=""
"IPM.Note.freshservice"=""
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\16.0\Outlook\Security]
"DisableCustomFormItemScript"=dword:00000000


This code works - I also added an item open, in part to change the email address but also to open the form to the Request tab - this works great if the recipient doesn't have the form installed (and its not in the org forms library)
Code:
Function Item_Send()
strNewBody = "Description: " & item.UserProperties.find("Description").Value & vbcrlf
strNewBody = strNewBody  & "Preconditions: " & item.UserProperties.find("Preconditions").Value & vbcrlf
strNewBody = strNewBody & "Steps to Recreate: " & item.UserProperties.find("Recreate").Value & vbcrlf
strNewBody = strNewBody  & "Actual Results: " & item.UserProperties.find("Results").Value & vbcrlf
strNewBody = strNewBody  & "What was expected: " & item.UserProperties.find("Expected").Value & vbcrlf
strNewBody = strNewBody  & "Additional Info: " & item.UserProperties.find("ExtraInfo").Value & vbcrlf
item.body = strNewbody
item.Save
End Function

Sub Item_Open()
  Item.GetInspector.SetCurrentFormPage("Request")
End Sub
2018-10-02_22-46-02.png
 
Last edited:

Scalpel4

New Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
#7
You are a WONDERFUL person! I'll test this out ASAP, and no worries for the spam!
 

Scalpel4

New Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
#8
Not having any luck with it. The recipient isn't an outlook client, its an automated system that processes HTML and plain text emails. I'll keep testing, maybe I'm doing something wrong, I probably missed something in the article.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
#9
Is the contents of the form being sent correctly? You should see this in your sent folder. If not, did you set the registry keys?

You need to publish the form and use the form name in the registry - AFAIK, you cant use vbscipt in templates any more (due to the security changes last summer).
"IPM.Note.freshservice"=""
 

Scalpel4

New Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
#10
Thanks. I'm seeing the data in the fields in my sent log, and if I send the data to a different recipient they get it in the fields, but I'm net getting the data to copy to the message body.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
#11
This is a message in the Sent folder in one of my test sends - The failures only have my signature.
2018-10-04_11-48-23.png
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
#13
You are sending it from your outlook to the freshservice account? If so, it should look like that in your sent folder.
 
Top