I have somewhat of an extensive request.
I have a system automated that, when our warranty team receives a warranty part that somebody else has requested information for, will email that person letting them know it has been received.
I want to include a hyperlink in the email that points to the database, opens it with 2 argument containing 2 variables in which one of the forms can auto populate and the information be shown immediately.
So first, I would like to know how to create a hyperlink within the code that sends the email. Second, I would like to know how have the database check for arguments upon opening. I can do the rest.
For instance, John Smith requested part number 123456 on claim number 55555, serial number 7777777. The database is located at "S:\Shared\Warranty Returns\Warranty Returns.accdb". Therefore, the hyperlink would aim at the location and carry the arguments 55555 and 7777777.
Current emailing code (obviously variables are passed into the function):
Code:
Function sendemail(msg As String, subj As String, recipients As String, ccrecipients As String, xclaim As Integer, claims() As Variant, serials() As Variant)Dim rsnote As Recordset
Set cdomsg = CreateObject("CDO.message")
If recipients <> "" Then
With cdomsg.Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smptserverport") = 587
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xx@xx.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "xxx"
.Update
End With
With cdomsg
.To = recipients
If ccrecipients <> "" Then .CC = ccrecipients
.From = "Warranty Returns"
.Subject = subj
.TextBody = msg
.Send
End With
Set rsnote = CurrentDb.OpenRecordset("Notification Table")
With rsnote
For d = 0 To xclaim
.AddNew
.Fields("Claim Number") = claims(d)
.Fields("Serial Number") = serials(d)
.Fields("Notified") = Format(Now(), "m/d/yyyy")
.Fields("Users Notified") = recipients & IIf(ccrecipients <> "", ", " & ccrecipients, "")
.Update
Next d
.Close
End With
Set rsnote = Nothing
Set cdomsg = Nothing
End If
End Function