Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Add link to e-mail from Microsoft Access to network folders

Posted on 2015-02-20
8
Medium Priority
?
167 Views
Last Modified: 2015-02-23
Hi,

I have an access database that is used for component tests, and once the tests are complete I want to send an e-mail from Access to notify a user that the test report is now available at a network location.

The location name is:-

\\bpl-sp\Inspection & Testing\Hardness Reports

No matter what I try I cannot make it get past the \\bpl-sp\Inspection part.

How can I tell access to send the full link in the e-mail?

Thanks

Les Shepherd
0
Comment
Question by:LJShepherd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 39

Expert Comment

by:PatHartman
ID: 40621284
We can't tell why you are having a problem.  A string is a string.  You may not be delimiting it correctly.  Please post your code.
0
 

Author Comment

by:LJShepherd
ID: 40621295
Hi Pat,

Here is the code I am using.

I can generate the e-mail, but can't get the link to work.

Thanks

Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)

strNewPath = "\\bpl-sp\Testing & Inspection\Hardness Reports\" & "SO" & Me.BPLSO & "-HR" & Me.POrderNo & ".pdf"



With MailOutLook
    .To = "it@beckprosper.com"
   
   
    .Subject = "Hardness Test " & "SO" & Me.BPLSO & "-HR" & Me.POrderNo
   
    .Body = "The Hardness Tests for " & "SO" & Me.BPLSO & "-HR" & Me.POrderNo & " have been completed and the report is now ready for inclusion in your document pack and can also be added to the Portal." & vbNewLine & vbNewLine & "The document can be found at this location " & vbNewLine & vbNewLine & strNewPath
   
    .Send
   
End With
 EditMessage = True
0
 
LVL 26

Accepted Solution

by:
Nick67 earned 2000 total points
ID: 40621490
How can I tell access to send the full link in the e-mail?
if you want the link to be clickable then you need an .HTMLBody and not a .Body

Dim TheHTML as string
TheHTML = "<p>The Hardness Tests for " 
TheHTML = TheHTML & "<a href = " & chr(34) & strNewPath & chr(34) & ">"
TheHTML = TheHTML & "SO" & Me.BPLSO & "-HR" & Me.POrderNo  & "</a>"
TheHTML = TheHTML & " have been completed and the report is now ready for inclusion in your document pack and can also be added to the Portal. <br><br></p>"

    .HTMLBody = TheHTML
Have a look at how to open Outlook in this article
http://www.experts-exchange.com/Programming/Microsoft_Development/A_17466-Properly-open-Outlook-as-an-Application-object-in-VBA.html

On Error Resume Next is an unhappy thing.
There are better ways to deal with Outlook being open or closed at run-time
0
What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

 
LVL 39

Expert Comment

by:PatHartman
ID: 40621774
I don't see any missing delimiters.  Could any of your variables contain the " character?  If so, you can use the single quote to delimit the string.  If the string could contain either, then use the double quote but add code to "escape" the embedded double quote by changing embedded " to "".
0
 

Author Comment

by:LJShepherd
ID: 40622276
Hi Pat,

Sorry, but I don't quite understand your comment.

If my path is "\\bpl-sp\Testing & Inspection\Hardness Reports\" & "SO" & Me.BPLSO & "-HR" & Me.POrderNo & ".pdf"

Where do I put the single quote please?

I don't believe any of my variables contain the " character.

Thanks

Les
0
 
LVL 26

Expert Comment

by:Nick67
ID: 40622345
I'm not sure about @Pat's comment either
Still
No matter what I try I cannot make it get past the \\bpl-sp\Inspection part.

To get a clickable link, you'll still need .HTMLBody and the string to be valid HTML
Build it up in chunks the way I've coded it.
You can drop a breakpoint on each line, or throw a MsgBox TheHTML between each line and debug in bits to see where the grief lies.

I can generate the e-mail, but can't get the link to work.
.Body is never going to permit a clickable link.
.Body is PlainText
A clickable link needs a .HTMLBody
0
 
LVL 85
ID: 40622348
Perhaps:

strNewPath = "\\bpl-sp\Testing & Inspection\Hardness Reports\SO" & Me.BPLSO & "-HR" & Me.POrderNo & ".pdf"

Also, here's an article about using Outlook to automate things like this:

http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/A_4316-Automate-Outlook-in-VBA-with-the-OutlookCreateItem-Class.html

It's got full source code and shows exactly how to create your objects, emails, etc.
0
 

Author Closing Comment

by:LJShepherd
ID: 40625909
Thanks for your input folks. I looked at the problem and messed around with the code that Nick67 provided and came up with the answer.

Cheers

Les Shepherd
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question