Solved

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

Posted on 2015-02-20
8
160 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 37

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 500 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 37

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 84
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
access vba 5 56
Handle Apostrophes in SQL Parameter 16 67
SQL using aggregate function with HAVING / WHERE clause. 8 49
Speed up Select Top n... Query 9 36
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
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.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

732 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