Inserting a hyperlink into an email using Word VBA

Status
Not open for further replies.

enizag

Member
HI




I am having difficulty acheiving this.


I have a word document which a user fills in, once complete the press a button, the form is saved and then I want the file path and filename to be embedded into the body of an email automatically, so the next person receives the email with a hyperlink to the specific form.


I have tried numerous approaches, this one will put a hyperlink in the email but when I click it, it can't find the file:


HTML:
<a href=file://" & szEmailTemp & ">click me</a></FONT></DIV>



I have used REPLACE to convert the spaces into %20, but still no luck.


I can't get the hyperlink to find the file I want, although it is there.


I send the email using the following:


Code:
Set smApp = CreateObject("outlook.application")
 
 
Set smMail = CreateObject("SecureEmail.SafeMailItem")
 
 
Set smItem = smApp.CreateItem(0)
 
 
Set myAttachments = smMail.Attachments



Code:
addFileName = "\\Nas080501\colleague\Shared Files\report requests\Requested reports\" & fName '& ".doc"
 
 
addFileName = Replace(addFileName, " ", "%20")



Code:
With smMail
   .HTMLBody = szEmailBody
   .Subject = emailSubject
   .ReadReceiptRequested = True
   .Recipients.Add returnEmail
   .Recipients.ResolveAll
   .Send
 
 
End With





Any help will be greatly appreciated.




Cheers :)
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Re: Inserting a hyperlink to a file using Word VBA

This works, please see the ' character the path is embedded in:

htmlbody="<a href='file://\\server\test\test.doc'>click</a>"

Of course, the path must be valid for the user.

Next time, please use microsoft.public.outlook.program_vba for programming

related questions.

Best regards

Michael Bauer

Am Wed, 9 Dec 2009 11:48:59 -0500 schrieb enizag:


> HI

> I am having difficulty acheiving this.
> I have a word document which a user fills in, once complete the press a
> button, the form is saved and then I want the file path and filename to
> be embedded into the body of an email automatically, so the next person
> receives the email with a hyperlink to the specific form.
> I have tried numerous approaches, this one will put a hyperlink in the
> email but when I click it, it can't find the file:
> <a href=file://" & szEmailTemp & ">click
> me</a></FONT></DIV
> I have used REPLACE to convert the spaces into %20, but still no luck.
> I can't get the hyperlink to find the file I want, although it is
> there.
> I send the email using the following:

> Code:
> ------------------> Set smApp = CreateObject("outlook.application")
> Set smMail = CreateObject("SecureEmail.SafeMailItem")
> Set smItem = smApp.CreateItem(0)
> Set myAttachments = smMail.Attachments
> ------------------
> Code:
> ------------------> addFileName = "\\Nas080501\colleague\Shared Files\report


requests\Requested reports\" & fName '& ".doc"
> addFileName = Replace(addFileName, " ", "%20")
> ------------------
> Code:
> ------------------> With smMail
> .HTMLBody = szEmailBody
> .Subject = emailSubject
> .ReadReceiptRequested = True
> .Recipients.Add returnEmail
> .Recipients.ResolveAll
> .Send
> End With

> ------------------
> Any help will be greatly appreciated.

> Cheers :)
 
Status
Not open for further replies.
Top