Using custom field data in mail body + mailto hyperlink

Status
Not open for further replies.

VincentM

New Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server 2010
I am breaking my head about this already for some time. I have a custom form for eventually creating an email with a mailto hyperlink inside the body.

In the custom form I define a.o. [product], [subject] and the [receivers] for the mailto hyperlink.
All the information is correctly computed corresponding fields.

1) How can I now make sure the [product] is going to be incorporated in the text of the mail:
e.g. bla bla bla [product] bla bla bla ?

2) How can I add the reply hyperlink, using the [subject] and [receiver] information from the custom fields.

The mails are send outside our company, but we want to force the suggested reply format by giving the mailto hyperlink. I would really appreciate any suggestions!
 

VincentM

New Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server 2010
Dear Diane and thanks for the quick respons,

I hoped to do everything in the one form; fill in the custom fields and send...
I guess, however this might be a work around for question 1, but how do I do this for question two, where I have to add the field values into a mailto hyperlink?
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
In that case, you should be able to use a formula to the fields together - create a new formula field and enter the url and the custom fields. The field won't be clickable though. To make a mailto link, you need to use HTML code to construct it.
 

VincentM

New Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server 2010
Hi Diana,
After some time finding bits and pieces, I have come quite far:

-----------
Sub StampDate()
Dim objOL As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objItem As Object
Dim strStamp As String
On Error Resume Next
Set objOL = Application
Set objItem = objOL.ActiveInspector.CurrentItem
If Not objItem Is Nothing Then
If objItem.BodyFormat = olFormatHTML Then
Set objNS = objOL.Session

strStyle = "'font-family:" & Chr(34) & "Calibri" & Chr(34) & ";color:black'"
strTextEng = "<p>" & "<span style=" & strStyle & ">" & "Please find attached the new order" & "<p>"

strLink = "<p>" & "<span style=" & strStyle & ">" & "<b><a href=" & Chr(34) & "mailto:someone@example.com?Subject=Confirmation" & Chr(34) & "target=" & Chr(34) & "_top" & Chr(34) & ">Hyperlink" & "</span></p></a></b>"


Set olkMsg = Outlook.Application.ActiveInspector.CurrentItem


objItem.HTMLBody = Replace(objItem.HTMLBody, "</body>", _
olkMsg.subject & strTextEng & strLink & "</body>", _
, , vbTextCompare)
End If
End If
Set objOL = Nothing
Set objNS = Nothing
Set objItem = Nothing

End Sub
---------

Al is working well and basically results is a the body of the mail including: 1) the subject line (olkMsg.subject), 2) a cutom text (strTextEng) + 3) the hyperlink (strLink).

I my custom form I have more fields which I can fill in, however in no way I am able to incorporate them in the body.
As with olkMsg.subject, I am able to use the value in To (olkMsg.to) / CC (olkMsg.cc) and BCC (olkMsg.bcc), but not any of my user identified fields e.g. PO number (e.g. olkMsg.TextBox1) or any else.

What am I missing??? Hope you can help me how to call on these custom fields.

PS Also I have been able to use the one of the fields to show correctly in the hyperlink, solving the custom hyperlink question, if I am able to use other user identified fields.

Hope you could help me.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Refer to custom fields as userproperties.
objItem.UserProperties("customfield")

Also, i see this:
Set olkMsg = Outlook.Application.ActiveInspector.CurrentItem

but you are referring to the fields as objItem:
objItem.HTMLBody = Replace(objItem.HTMLBody, "</body>", _

actually, you set the current item twice.
 

VincentM

New Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server 2010
Hi Diane,

Can you help me a bit further, I have adjusted as follows to add value of Textbox31 in the body as well, however now the macro is not working:

objItem.HTMLBody = Replace(objItem.HTMLBody, "</body>", _
objItem.UserProperties("TextBox31") & olkMsg.subject & strTextEng & strLink & strTextCh & strTextCh2 & "</body>", _
, , vbTextCompare)

Also, It seems I need Set olkMsg = Outlook.Application.ActiveInspector.CurrentItem, as it will not show olkMsg.subject when I delete it.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
objItem and olkMsg are the same message... what you need to do is change the olkmsg to objitem

objItem.UserProperties("TextBox31") & olkMsg.subject & strTextEng & strLink & strTextCh & strTextCh2 & "</body>", _
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
K can't get custom form to update multiple contacts using VBA Outlook VBA and Custom Forms 3
D Using a VBA Custom Form to Send Reoccurring Email Upon Task Completion Outlook VBA and Custom Forms 4
Z Adding dropdown list using custom form Outlook VBA and Custom Forms 7
D create an html table in outlook custom form 2010 using vba in MsAccess Outlook VBA and Custom Forms 7
G Adding a contact to Outlook with a custom form using Access VBA Outlook VBA and Custom Forms 1
D Using Follup in Custom Forms Outlook 2013 Using Outlook 9
M Outlook 2013 won't convert Excel contacts into Outlook contacts using my custom form Using Outlook 3
R Viewing & Using custom forms/tasks in Outlook 2013 Using Outlook 1
L reply to message using a custom template Using Outlook 1
A Using custom form Outlook VBA and Custom Forms 2
W Using a PropertyAccessor custom datetime property in Views Outlook VBA and Custom Forms 3
C Using my custom form with a public folder Outlook VBA and Custom Forms 6
C Deployment of custom form using "setup.exe" Outlook VBA and Custom Forms 4
J Outlook 2007 using custom form created for Outlook 2003 Outlook VBA and Custom Forms 2
D Outlook 2021 Using vba code to delete all my spamfolders not only the default one. Outlook VBA and Custom Forms 0
M using excel to sort outlook appointment items Outlook VBA and Custom Forms 4
R Advise on using multiple instances of network files based on customers Outlook VBA and Custom Forms 8
HarvMan Using Emojis in Outlook 365 Using Outlook 3
T Outlook 2019 Not Using Auto Compete After Deletion of 365 Using Outlook 1
M USING INITIALS AS RECIPIENTS Using Outlook 1
T Outlook 2019 Using Gmail aliases in Outlook Using Outlook 6
M Saving emails using Visual Basic - Selecting folder with msoFileDialogFolderPicker Outlook VBA and Custom Forms 6
Z Import Tasks from Access Using VBA including User Defined Fields Outlook VBA and Custom Forms 0
justicefriends How to set a flag to follow up using VBA - for addressee in TO field Outlook VBA and Custom Forms 11
M Extract "Date sent" from emails (saved to folder using drag and drop) Outlook VBA and Custom Forms 1
I Outlook for Mac 2019 using on desktop and laptop IMAP on both need help with folders Using Outlook 1
David McKay VBA to manually forward using odd options Outlook VBA and Custom Forms 1
H Stationery using between OL 2019 and OL 2010 Using Outlook 0
P Prevent Outlook 2016 from using DASL filter Using Outlook 4
O Calendar - Location: what happens when using my own way of entering locations Using Outlook 1
M Disable Contact Card Results when using "Search People" in Outlook Ribbon Using Outlook 7
S Outlook VBA How to adapt this code for using in a different Mail Inbox Outlook VBA and Custom Forms 0
pcunite Outlook 2019/O365 Build 13127.20408 errors when using MAPI calls Using Outlook 1
B Change Font and Font size using VBA Outlook VBA and Custom Forms 9
M Outlook 2013 reminder email by using Outlook vba Outlook VBA and Custom Forms 2
X Using Outlook 2013 and Outlook 365 Using Outlook 1
A Going to folder using shortcuts Using Outlook 3
A Outlook replies not using "delivered to" address in From Using Outlook 1
Terry Sullivan E-Mails Sent Using a Group Box Result in 70 Kickbacks Using Outlook 4
O Email not leaving Outbox when using Excel VBA to sync Outlook account Outlook VBA and Custom Forms 4
K Using Outlook 2016 to draw Using Outlook 1
O Outlook 365 - suddenly unable to send using Gmail POP3 Using Outlook 10
N Disable Auto Read Receipts sent after using Advanced Find Using Outlook 4
G Outlook 2016 sync contacts directly between phone and computer using outlook 2016 Using Outlook 0
L Moving emails with similar subject and find the timings between the emails using outlook VBA macro Outlook VBA and Custom Forms 1
O Save attachments using hotkey without changing attributes Outlook VBA and Custom Forms 1
J Add an Attachment Using an Array and Match first 17 Letters to Matching Template .oft to Send eMail Outlook VBA and Custom Forms 2
A Edit subject - and change conversationTopic - using VBA and redemption Outlook VBA and Custom Forms 2
A Using or not using apostrophes in search terms has this changed? Using Outlook 0
O Office 365 using POP3 on both laptop and desktop Using Outlook 0

Similar threads

Top