PDA

View Full Version : Using Access to Email a Hyperlink



n8Mills
09-20-2006, 11:57 AM
Hello, All!

I'm having some fun here, the Google search yields no answers. I have the following code:



Sub sbRECtoCSR(Optional AttachmentPath)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim cmbRecCStext As String
Dim txtNotifText As String
Dim body_ As String
Dim StopDet As String
Dim Customer As String

'Forces a Notification Number entry
If Form_ReceivingShipping.txtRecNotif.Value = "" Or IsNull (Form_ReceivingShipping.txtRecNotif.Value) Then
MsgBox "Please input a Notification"
Form_ReceivingShipping.txtRecNotif.SetFocus
Exit Sub
End If

On Error GoTo ErrorMsgs
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' Add the To recipient(s) to the message. Substitute
' your names here.
'Set objOutlookRecip = .Recipients.Add(Form_ReceivingShipping.cmbRecCS.Value)

'Add the CC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("MILLS Nathanael")
objOutlookRecip.Type = olTo
'objOutlookRecip.Type = olCC
' Set the Subject, Body, and Importance of the message.
.Subject = "Receiving Alert, NN " & Form_ReceivingShipping.txtRecNotif.Value
'If Form_ReceivingShipping.txtStopDetails.Value = 0 Then
'StopDet = "No details has been provided on this Work Stoppage"
'End If
'If Form_ReceivingShipping.txtStopDetails.Value <> 0 Then
'StopDet = Form_ReceivingShipping.txtStopDetails.Value
'End If
.Body = Form_ReceivingShipping.cmbRecCS.Value & "," & vbCrLf & vbCrLf & " Our customer " & Form_ReceivingShipping.txtRecCust.Value _
& " has sent in a repair on the PO " & Form_ReceivingShipping.txtRecCustPO.Value & ". The Notification " _
& Form_ReceivingShipping.txtRecNotif.Value & " has been opened for this repair." & vbCrLf & StopDet & vbCrLf & _
"Please review the linked PO and associated customer paperwork, the unit will be delivered to the lab when your Workshop Report is received in Shipping/Receiving" _
& vbCrLf & vbCrLf & "Thank you," & vbCrLf & vbCrLf & "The Shipping & Receving Dept"
.Importance = olImportanceHigh 'High importance
' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If
' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
'End If
End If
Next
.Send
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
Set objOutlookRecip = Nothing
Set objOutlookAttach = Nothing

ErrorMsgs:
If Err.Number = "287" Then
MsgBox "You clicked No to the Outlook security warning. "
'"Rerun the procedure and click Yes to access e-mail" & _
' "addresses to send your message. For more information, & _
'"see the document at microsoft.com/office" & _
'"/previous/outlook/downloads/security.asp. " "
Else
'MsgBox Err.Number, Err.Description
End If

End Sub



I'd like to drop the Hyperlink into the body:



.Body = Form_ReceivingShipping.cmbRecCS.Value & "," & vbCrLf & vbCrLf & " Our customer " & Form_ReceivingShipping.txtRecCust.Value _
& " has sent in a repair on the PO " & Form_ReceivingShipping.txtRecCustPO.Value & ". The Notification " _
& Form_ReceivingShipping.txtRecNotif.Value & " has been opened for this repair." & vbCrLf & StopDet & vbCrLf & _
"Please review the linked PO and associated customer paperwork, the unit will be delivered to the lab when your Workshop Report is received in Shipping/Receiving" _
& vbCrLf & vbCrLf & "Thank you," & vbCrLf & vbCrLf & "The Shipping & Receving Dept"



So far all my efforts have fallen flat. Can anyone clarify?

Thanks,

n8

Ken Puls
09-20-2006, 03:17 PM
Hi there,

I don't have Outlook here, but I thought that there was an HTMLBody as well. You may want to look at that. :)

n8Mills
09-20-2006, 04:58 PM
It actually won't go out to the internet, I just mean to point it at a folder on one of the public drives.

I saw where somebody used .HyperLink = "folder\file" but that didn't work. It didn't kick out an error, either though.

Maybe I'll try it again.

Ken Puls
09-21-2006, 08:54 AM
Sorry, I thought you wanted to include a hyperlink in the body of the email. My thought was to create it using the html tags and insert it into the body...