Syntax Question

TheSearcher

Registered User.
Local time
Today, 02:08
Joined
Jul 21, 2011
Messages
408
Hello All,
I have a procedure called eMailit in an Access 2010 database that sends emails.

eMailIt(ByVal eMailBody As String, ByVal emailAddress As String, ByVal SenderCode As String)

The syntax I use to call the procedure is:

eMailIt "file:///c:\Myfolder\notes.doc", "YourEmail@YourServer.com", "E"

When I receive the email the eMailBody contains the actual path (c:\Myfolder\notes.doc). How can I set the 'text to display' to read "Notes"? The idea is to have the user click on "Notes" and then be taken to the actual path.

Thanks in Advance,
TS
 
You will need to send the email in HTML format, and add a hyperlink as the normal HTML way.
 
Thanks nathansav - but when I send the "< a href" code I actually see "<a href".
I'm not sure what I'm doing wrong. How can I send the link to my network location using "HTML format?
 
Can you show us the complete code for eMailIt ?
 
you need to change the .body to be htmlbody or bodyhtml, in your email sub
 
Sure. Here it is. The code works fine. I just want to be able to pass a link to a network file in the eMailBody part.

Public Sub eMailIt(ByVal eMailBody As String, ByVal emailAddress As String, ByVal SenderCode As String)

Dim strBody As String
Dim strEmail As String
Dim strSubject As String
Dim strCC As String
Dim strPathAttach As String
Dim objOutlook As Object
Dim objMailItem As Object
Const olMailItem As Integer = 0
Set objOutlook = CreateObject("Outlook.Application")
Set objMailItem = objOutlook.CreateItem(olMailItem)
strEmail = emailAddress
Select Case SenderCode
Case "E" 'Sent by Employee
strSubject = "A Direct Report Has Requested Time Off"
Case "S" 'Sent by Supervisor
strSubject = "Your Requested Time Off has been Approved."
Case "SD" 'Sent by Supervisor but Request Denied
strSubject = "Your Requested Time Off has been Denied."
Case "EC" 'Sent by Employee. Employee cancelled time off.
strSubject = "A Direct Report Has CANCELLED Out of Office Time."
Case "SDWH" 'Sent by Supervisor Work Hours Denied
strSubject = "Your Work Time Hours have been Denied."
End Select

strBody = eMailBody
On Error GoTo err_Error_handler
objMailItem.To = strEmail
objMailItem.Subject = strSubject
objMailItem.Body = strBody

objMailItem.Send
Set objOutlook = Nothing
Set objMailItem = Nothing

exit_Error_handler:
On Error Resume Next
Set objOutlook = Nothing
Set objMailItem = Nothing

Exit Sub

err_Error_handler:
Select Case Err.Number
'trap error 287
Case 287
MsgBox "Canceled by user.", vbInformation
Case Else
MsgBox "Error " & Err.Number & " " & Err.Description
End Select
Resume exit_Error_handler
End Sub
 
As the other poster has pointed out use HTML Body..
Code:
Public Sub eMailIt(ByVal eMailBody As String, ByVal emailAddress As String, ByVal SenderCode As String)
On Error GoTo err_Error_handler
    Dim strSubject As String
    Dim strCC As String, strPathAttach As String
    
    Dim objOutlook As Object, objMailItem As Object
    
    Const olMailItem As Integer = 0
    
    Set objOutlook = CreateObject("Outlook.Application")
    Set objMailItem = objOutlook.CreateItem(olMailItem)

    Select Case SenderCode
        Case "E"[COLOR=Green] 'Sent by Employee[/COLOR]
            strSubject = "A Direct Report Has Requested Time Off"
        Case "S" [COLOR=Green]'Sent by Supervisor[/COLOR]
            strSubject = "Your Requested Time Off has been Approved."
        Case "SD" [COLOR=Green]'Sent by Supervisor but Request Denied[/COLOR]
            strSubject = "Your Requested Time Off has been Denied."
        Case "EC"[COLOR=Green] 'Sent by Employee. Employee cancelled time off.[/COLOR]
            strSubject = "A Direct Report Has CANCELLED Out of Office Time."
        Case "SDWH" [COLOR=Green]'Sent by Supervisor Work Hours Denied[/COLOR]
            strSubject = "Your Work Time Hours have been Denied."
    End Select
    
    objMailItem.To = emailAddress
    objMailItem.Subject = strSubject
    objMailItem.[COLOR=Red][B]HTMLBody[/B][/COLOR] = eMailBody

    objMailItem.Send
    Set objOutlook = Nothing
    Set objMailItem = Nothing

exit_Error_handler:
    On Error Resume Next
    Set objOutlook = Nothing
    Set objMailItem = Nothing

    Exit Sub
err_Error_handler:
    Select Case Err.Number
        [COLOR=Green]'trap error 287[/COLOR]
        Case 287
            MsgBox "Canceled by user.", vbInformation
        Case Else
            MsgBox "Error " & Err.Number & " " & Err.Description
    End Select
    Resume exit_Error_handler
End Sub
 

Users who are viewing this thread

Back
Top Bottom