HYPERLINK "mailto:test@test.com" in form body

Status
Not open for further replies.

Witzker

Senior Member
Outlook version
Outlook 2019 64-bit
Email Account
POP3
Hallo,

In my user defined form I use a macro to write text in the form body.
The code:

Item.Body = Item.Body & vbCrLf & Date() & " - " & FormatDateTime(Time,4) & ": "
Set objWSHShell = CreateObject("WScript.Shell")
objWSHShell.SendKeys("{TAB 11}")
objWSHShell.SendKeys("^{End}")
objWSHShell.SendKeys("^{backspace}")

It works fine but I noticed that, when I have an email address in the body, it changes from:
eg: test@test.com to: HYPERLINK "mailto:test@test.com" test@test.com
each time the button with the code is pressed
another: HYPERLINK "mailto:test@test.com" is added

are there some settings in outlook?
something wrong with the code?
How can I solve this?

Many thanks for your help.
Regards
WITZKER
 
Thx for reply

Tried Item.HTMLBody for one and both.
Result: ERROR

Iam using german version:
Das Objekt unterstützt die Eigenschaft oder Objekt nicht
The object dosn't support attribute or objekt

Pls note the code is in the OL form Code
What I learned from other therad there is used vbscipt.

Lookin forward to a solution
 
Diane! Great idea

As you see I'm already using sendkeys in the code to go to the bottom of the body.

It would be great if you would be so kind and let me have the code to insert the text:

vbCrLf & Date() & " - " & FormatDateTime(Time,4) & ": "

if possible also in red letters?

Regards Witzker
 
Red will be complicated... and I can't get sendkeys to work at all in my test form. :(
 
Dear Diane,

many thanks for your effort.

Is it possible to do this in a VBA macro which is located in a module instead of the code in the user definde form where only VBSkript is available?

can Item.HTMLBody be used in VBA?

If Yes what VBA code would you suggest?

The procedure for using this macro could be

open the contact
and call the macro from the ribbon.

What do you think?

Thanks Witzker
 
Oh, yes, it will work perfectly in VBA. You'll be able to use HTMLBody, formatting the time could be easier, and you can add color. I might already have something on slipstick that comes close but I have a meeting coming up and can't look for it right now. Give me 3 or 4 hours and if I haven't updated this thread, remind me. :)
 
Re: HYPERLINK "mailto:test@test.com" in form body

Ok... messy is my middle name :) It could be a little cleaner and neater, but it does the job.

I tweaked the macro at http://www.slipstick.com/developer/word-macro-apply-formatting-outlook-email/ to insert the date at the bottom of the page and move the cursor back to the top.

Code:
 Public Sub FormatSelectedText() 
    Dim objItem As Object 
    Dim objInsp As Outlook.Inspector 
    
   ' Add reference to Word library 
    ' in VBA Editor, Tools, References 
    Dim objWord As Word.Application 
    Dim objDoc As Word.Document 
    Dim objSel As Word.Selection 
    On Error Resume Next 
   
   
 
'Reference the current Outlook item 
    Set objItem = Application.ActiveInspector.currentItem 
    If Not objItem Is Nothing Then 
        If objItem.Class = olMail Then 
            Set objInsp = objItem.GetInspector 
            If objInsp.EditorType = olEditorWord Then 
                Set objDoc = objInsp.WordEditor 
                Set objWord = objDoc.Application 
                Set objSel = objWord.Selection 
    
   'move to end of message 
objSel.EndKey Unit:=wdStory 
 
set formatting 
       With objSel 
       ' Formatting code goes here 
            .Font.Color = wdColorBlue 
            .Font.Size = 18 
            .Font.Bold = True 
            .Font.Italic = True 
            .Font.Name = "Arial" 
       End With 
   
 
'adds a line break 
       objSel.Range.InsertParagraphAfter 
 
'inserts date & time in 3/7/2014 12:55 format 
         objSel.Range.InsertAfter "Time Stamped at " & Date & Format(Time, " hh:mm") 
    
 
' another linebreak 
    objSel.Range.InsertParagraphAfter 
 
'jump back to the top 
objSel.HomeKey Unit:=wdStory
           End If 
        End If 
    End If 
    
   Set objItem = Nothing 
    Set objWord = Nothing 
    Set objSel = Nothing 
    Set objInsp = Nothing 
End Sub
 
Re: HYPERLINK "mailto:test@test.com" in form body

THX GREAT :)

i will adapt the code for a contct form and put it in Module 2

How can I start the macro from a custom botton in the form code

Sub CommandButton1_Click
HOW to start the macro in Module2 ??
End Sub

I hope you can let me have the code
regards
Witzker
 
Re: HYPERLINK "mailto:test@test.com" in form body

You can use this:

Sub CommandButton1_Click
FormatSelectedText
End Sub

Or add a button to the QAT or ribbon for the macro - file, options, customize ribbon or quick access toolbar. Select Macros from the dropdown and add to the ribbon or QAt.
 
Re: HYPERLINK "mailto:test@test.com" in form body

Thx

I have tried:
Sub CommandButton1_Click
FormatSelectedText
End Sub
in the code of custom form

also tried
FormatSelectedText()
run FormatSelectedText
run FormatSelectedText()
Error:
Typenkonflikt "FormatSelectedText"

sorry
where is the problem?

Hope for a solution
 
Re: HYPERLINK "mailto:test@test.com" in form body

According to http://support.microsoft.com/kb/221827/ if the macro is in ThisOutlooksession and you call it using Application.macroname, it may work, but it's not recommended or supported.

- - - Updated - - -

It's not working for me in Outlook 2013.
 
Re: HYPERLINK "mailto:test@test.com" in form body

You can use this:

Sub CommandButton1_Click

FormatSelectedText

End Sub


Or add a button to the QAT or ribbon for the macro - file, options, customize ribbon or quick access toolbar. Select Macros from the dropdown and add to the ribbon or QAt.
 
Re: HYPERLINK "mailto:test@test.com" in form body

Thx
is there another way to call a macro from ol form?
toad a field or dropdown with macros?
button wouldbe best

Hope for a solution or woraround
 
Re: HYPERLINK "mailto:test@test.com" in form body

You can add a button to the QAT or to the ribbon. You can't make dropdown buttons, but if you need dropdowns, you can use userforms.

see How to use the VBA editor - down at the bottom is instructions to create buttons on the ribbon.
 
Re: HYPERLINK "mailto:test@test.com" in form body

You can add a button to the QAT or to the ribbon. You can't make dropdown buttons, but if you need dropdowns, you can use userforms.


see How to use the VBA editor - down at the bottom is instructions to create buttons on the ribbon.
 
@your post Diane
According to http://support.microsoft.com/kb/221827/ if the macro is in ThisOutlooksession and you call it using Application.macroname, it may work, but it's not recommended or supported.

in this article at the bottom is the solution to call the vba macro from the button!?:
As an alternative to calling Visual Basic for Applications code from VBScript, you can create a Visual Basic automation server, install it using a Visual Basic Setup program, and then launch the Visual Basic component by using the CreateObject method in VBScript.

Ok - but I do not understand how to do this.

I think to be able to call a VBA Macro (with all possibilities of VBA) from an OL Form with a button gives a lot possibility in realizing custom projects.

So I hope for further help on this topic.

Regards
Witzker
 
Hi again
for the case there is really no solution to start a VBA macro with the form code I am thinking of a work around to add some buttons into the ribbon and as suggested use a user form in VB for the other macros.

First step would be following task:

I open a contact
than click on phone, to make a telephone call to the contact
Then I have to run the macro that inserts date & time and the person who called the contact in the body. (which is now working fine with your code)

It would be great when I can open the phone dialog at the beginning of the macro which inserts the date & time ....

I tried with sendkeys " STRG+Shift+D" - SendKeys "^+{D}"

I got the phone dialog open where I can start the call, but in in its window all fields are empty - meaning there is no number to call in the box.

So my question is:
If you would be so kind and let me have the code that opens the phone dialog like pressing the phon button in the ribbon of an opened contact.

Many thanks in advance
Regards
Witzker
 
I'm not sure the phone dialog is accessible via VBA, but will look into it.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
V Using custom field data in mail body + mailto hyperlink Outlook VBA and Custom Forms 7
V Embedding hyperlink into Word document Using Outlook 2
Y Open and Save Hyperlink Files in multiple emails Outlook VBA and Custom Forms 9
L Ignore hyperlink from being flagged as false pattern Outlook VBA and Custom Forms 3
D Custom form with html hyperlink Outlook VBA and Custom Forms 7
N open the hyperlink in Outlook directly instead of browser Using Outlook 1
M VBA Rule for removing all body but hyperlink then forwarding Outlook VBA and Custom Forms 9
M How to view the URL for a hyperlink? Using Outlook 1
A Add Hyperlink to Task Outlook VBA and Custom Forms 11
Q Why can't I copy image with embedded hyperlink from email to Word Using Outlook 0
P URL Hyperlink not working correctly in Outlook 2003 Using Outlook 10
A Create Macro for hyperlink(email) in message body Outlook VBA and Custom Forms 9
Diane Poremsky Disable the Unsafe Hyperlink Warning when Opening Attachments Using Outlook 0
C Hyperlink to an Outlook search Using Outlook 1
makinmyway Recent Files Not Updating when Using Insert Hyperlink in Outlook 2013 Using Outlook 0
E Create a URL hyperlink in an Outlook custom form? Outlook VBA and Custom Forms 2
J Macro generating email using default signature and hyperlink Outlook VBA and Custom Forms 5
Hudas Hyperlink Saved Outlook Email to MS Access Table Using Outlook 4
D Particular Facebook "Hyperlink" Issue In Office 2010 Outlook (32 bit) Using Outlook 5
S email body without "HYPERLINK" ( vba ) Using Outlook 6
M How to create a hyperlink to to an organizational form Using Outlook 5
J Hyperlink VBA Using Outlook 1
P Can't add a custom hyperlink to toolbar in OL 2010 Using Outlook 1
T Desable Hyperlink on email Using Outlook 3
O Hyperlink formatting lost after replacement in outlook Using Outlook 5
O Hyperlink formatting lost after replacement in outlook Using Outlook 0
G Hyperlink Using Outlook 1
T Hyperlink Issue Using Outlook 2
P Hyperlink to Access record/Form Outlook VBA and Custom Forms 2
M auto click hyperlink?! Outlook VBA and Custom Forms 1
M Auto click a hyperlink Outlook VBA and Custom Forms 2
R Inserting a hyperlink in the bod of an outlook appt. Outlook VBA and Custom Forms 13
K Add Hyperlink in Email Body by VBA Outlook VBA and Custom Forms 1
G <mailto:user@domain.com<mailto:user@domain.com<mailto:user@domain.com>>> Using Outlook 5
P mailto replication in Outlook Contact Notes Using Outlook 4
R Mailto link inside Outlook 2010 being cached? Using Outlook 1
mrje1 mailto links in browsers don't open up outlook email Using Outlook 2
R Some Mailto items dont work Using Outlook 3
Diane Poremsky Test 2 Using Outlook 0
Y Disable Microsoft Outlook Test Message Using Outlook 4
S SendFromAccount - Problem trying to test existing value in open email Outlook VBA and Custom Forms 2
Diane Poremsky test Using Outlook 2
M Change default "automatically test account settings when Next is clicked" Using Outlook 1
A Outlook 2010 - Want to Have All Email Reply Forward as Rich Test Using Outlook 7
R Test if cursor is in To... field Outlook VBA and Custom Forms 1
H Sending a test email to sender's own account. Outlook VBA and Custom Forms 3

Similar threads

Back
Top