Email hyperlink/attachment to open Access file (1 Viewer)

sbflood

Registered User.
Local time
Today, 00:19
Joined
Feb 26, 2014
Messages
16
Hello,

I have created an action log database that sends an email when a new action is entered. I would like to launch the database using a hyperlink in the email, but can't seem to get it to work. All users have a copy of the front end on their desktop, so whatever I add to the email needs to launch the front end for any user signed on to their own desktop.

This is what I have and it sends a hyperlink but I click it, I get an error saying it can't find the file. I don't know how to word the path name for any user, is this even possible?

With obMsg
.subject = "New action request for " & team
.To = people
.Body = "A new action request has been submitted to " & team & vbNewLine & "Priority: " & prior & vbNewLine & _
"Requester: " & requester & vbNewLine & "Issue Description: " & iss & vbNewLine & vbNewLine & _
"Please click here to open the Action Log: file:\\Desktop\Action_Log.accdb"
.Send
End With


Thanks for the help!
 

robslob

Registered User.
Local time
Today, 05:19
Joined
Apr 26, 2015
Messages
27
I believe I got this working but only in Outlook, are you using a different client?
 

sbflood

Registered User.
Local time
Today, 00:19
Joined
Feb 26, 2014
Messages
16
No, I am using Outlook.
 

robslob

Registered User.
Local time
Today, 05:19
Joined
Apr 26, 2015
Messages
27
It could be an issue with network files or permissions on them, I would try your code with a local copy of the db file just to iron out that possibility.

Come to think of it I would normally expect a share file path to be \\server\foldername\filename.ext
 
Last edited:

sbflood

Registered User.
Local time
Today, 00:19
Joined
Feb 26, 2014
Messages
16
I'm not sure about the file permissions, but it's definitely an error about not finding the file, not about having permission.

I've tried many different versions of the file path but none of them have worked. I guess that's the part I'm looking for help on.
 

robslob

Registered User.
Local time
Today, 05:19
Joined
Apr 26, 2015
Messages
27
I will expand on my last reply by example

Your file path looks like it's on a shared folder named Desktop but it looks like your missed off the server name (or the name of your pc). Or it could be that your pc is called Desktop and you missed off the shared folder name.

On my pc it would be:
.body = "Blah Blah file:\\asus\sharetest\ODS-live.accdb"

However for a local file it would be:
.body = "Blah Blah file:C:\Users\Rob\Desktop\sharetest\ODS-live.accd"
 

sbflood

Registered User.
Local time
Today, 00:19
Joined
Feb 26, 2014
Messages
16
I see. You're right, that is the typical file path that should be used but that won't work for me because I need one email to be sent to several people that will open a file on their own desktops. So what I need is a way to reference the desktop without a specific user name in the path.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 05:19
Joined
Feb 19, 2013
Messages
16,653
not tested but the following path should take the user to the Action_Log.accdb file on their desktop

%UserProfile%\Desktop\Action_Log.accdb
 

Solo712

Registered User.
Local time
Today, 00:19
Joined
Oct 19, 2012
Messages
828
:
"Please click here to open the Action Log: file:\\Desktop\Action_Log.accdb"
.Send
End With

Thanks for the help!

I haven't done this in a while but I believe you have to explicitly create a hyperlink on the line with HTML, like :
Code:
"Please click <A HREF=""file://%USERPROFILE%\Desktop\Action_Log.accdb"">here</A> to open the Action Log"
.Send

Best,
Jiri
 

sbflood

Registered User.
Local time
Today, 00:19
Joined
Feb 26, 2014
Messages
16
Thank you both for the suggestions, but nothing happens when I click the link. No errors, but no file either.

Solo712, this is how the link shows up in the email (it shows all the hyperlink code but only the stuff inside the quotes is blue).
Please click <A HREF="file://%USERPROFILE%\Desktop\Action_Log.accdb">here</A> to open the Action Log
 

Solo712

Registered User.
Local time
Today, 00:19
Joined
Oct 19, 2012
Messages
828
Thank you both for the suggestions, but nothing happens when I click the link. No errors, but no file either.

Solo712, this is how the link shows up in the email (it shows all the hyperlink code but only the stuff inside the quotes is blue).
Please click <A HREF="file://%USERPROFILE%\Desktop\Action_Log.accdb">here</A> to open the Action Log

Ok. Two things: to get the HTML to work you need the <HTML><BODY> at the start of the text and </BODY> at the end. But the fact that the code shows in blue is encouraging. The stuff inside the quotes is read as hyperlink. So the issue is with the path to the log. Is there an Action_Log.accdb on the desktop of the user who is testing thos code ?
Also try this
Code:
"file://C:\Users\%USERPROFILE%\Desktop\Action_Log.accdb"

Best,
Jiri
 

sbflood

Registered User.
Local time
Today, 00:19
Joined
Feb 26, 2014
Messages
16
Forgive my HTML ignorance but I'm still getting the code in the email. Did I put it in the wrong place?

Code:
With obMsg
            .subject = "New action request for " & team
            .To = people
            .Body = "A new action request has been submitted to " & team & vbNewLine & "Priority: " & prior & vbNewLine & _
                "Requester: " & requester & vbNewLine & "Issue Description: " & iss & vbNewLine & vbNewLine & _
                "Please click <HTML><BODY><A HREF=""file://C:\Users\%USERPROFILE%\Desktop\Action_Log.accdb"">here</A></BODY> to open the Action Log"
            .send
        End With

This time the link tried to open a file but said it couldn't be found. The path in the error message had %USERPROFILE% (it didn't replace that with my username) so maybe that's not working?

I'm the only one testing the code until I can get this working and I definitely have the file on my desktop. I'm sending the email to myself, closing the database, and then attempting to open it again via the link.
 

Solo712

Registered User.
Local time
Today, 00:19
Joined
Oct 19, 2012
Messages
828
Forgive my HTML ignorance but I'm still getting the code in the email. Did I put it in the wrong place?

Code:
With obMsg
            .subject = "New action request for " & team
            .To = people
            .Body = "A new action request has been submitted to " & team & vbNewLine & "Priority: " & prior & vbNewLine & _
                "Requester: " & requester & vbNewLine & "Issue Description: " & iss & vbNewLine & vbNewLine & _
                "Please click <HTML><BODY><A HREF=""file://C:\Users\%USERPROFILE%\Desktop\Action_Log.accdb"">here</A></BODY> to open the Action Log"
            .send
        End With

This time the link tried to open a file but said it couldn't be found. The path in the error message had %USERPROFILE% (it didn't replace that with my username) so maybe that's not working?

I'm the only one testing the code until I can get this working and I definitely have the file on my desktop. I'm sending the email to myself, closing the database, and then attempting to open it again via the link.

Hmmm...Ok Let's not worry about the HTML now...Try:

Code:
"Please click [URL]file://C:\Users\%USERPROFILE%\Desktop\Action_Log.accdb[/URL] to open the Action Log"

I think this is the correct notation...the userprofile should kick in. I think the problem was that HTML garbage.

Best,
Jiri
 

sbflood

Registered User.
Local time
Today, 00:19
Joined
Feb 26, 2014
Messages
16
Sorry, still not working. Getting this error:

Cannot find file 'C:\Users\%USERPROFILE%\Desktop\Action_Log.accdb'. Verify the path or Internet address is correct.
 

robslob

Registered User.
Local time
Today, 05:19
Joined
Apr 26, 2015
Messages
27
From what I've looked into, environment variables don't work well with the File:/// URI. However you can send individual emails by using a recordset, you just need a table containing the pc usernames and then build up the hyperlink using those usernames.
 

Solo712

Registered User.
Local time
Today, 00:19
Joined
Oct 19, 2012
Messages
828
Sorry, still not working. Getting this error:

Cannot find file 'C:\Users\%USERPROFILE%\Desktop\Action_Log.accdb'. Verify the path or Internet address is correct.

Can you test the link with an actual user name ?

Best,
Jiri
 

Solo712

Registered User.
Local time
Today, 00:19
Joined
Oct 19, 2012
Messages
828
Sorry, still not working. Getting this error:

Cannot find file 'C:\Users\%USERPROFILE%\Desktop\Action_Log.accdb'. Verify the path or Internet address is correct.

Sorry, that should have been %USERNAME% but anyways, I checked both the variables used and though the link shows as active, the conversions do not work. I had a file from way back in which I did it with the HTML gizmos. Can't seem to find it now. Sorry.
 

Users who are viewing this thread

Top Bottom