mailto: by Dl clicking, how to open Lotus Notes instead of Outlook

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have coded the EmailAddress control as seen in some help messages regarding
the above, i.e. :
Private Sub EmailAddress_DblClick(Cancel As Integer)
On Error GoTo ErrorPoint

Dim strEmail As String

' Stop the Web Toolbar from appearing
DoCmd.ShowToolbar "Web", acToolbarNo

If Not IsNull(Me.EmailAddress) Then
strEmail = Me.EmailAddress
If Left(strEmail, 7) <> "mailto:" Then
strEmail = "mailto: " & strEmail
End If
Application.FollowHyperlink strEmail
End If

ExitPoint:
Exit Sub

ErrorPoint:
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " _
& Err.Description, vbExclamation, _
"Unexpected Error"
Resume ExitPoint

End Sub

OR simplest : Application.FollowHyperlink "Mailto:" &EmailAddress

But how to open Lotus Notes (our Email program) instead of Outlook.
Thank in advance for your helps.
 
You will need to make sure you have added a reference to Lotus Domino
Objects first.

The following code should help you.

Public Sub SendNotesMail(strSubject As String, ByVal strRecipient As String,
strBodyText As String, Optional blnSave As Boolean = True, Optional ByVal
strCCTo As String = "", Optional ByVal strAttachment As String = "")
On Error GoTo SendNotesMailError

'Set up the objects required for Automation into lotus notes
Dim Maildb As Object 'The mail database
Dim UserName As String 'The current users notes name
Dim MailDbName As String 'THe current users notes mail database name
Dim MailDoc As Object 'The mail document itself
Dim AttachME As Object 'The attachment richtextfile object
Dim Session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object (Attachment)
Dim strAttach As String, strCopyTo() As String
Dim intCnt As Integer

'Start a session to notes
Set Session = CreateObject("Notes.NotesSession")

'Get the sessions username and then calculate the mail file name
'You may or may not need this as for MailDBname with some systems you
'can pass an empty string
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) -
InStr(1, UserName, " "))) & ".nsf"

'Open the mail database in notes
Set Maildb = Session.GetDatabase("", MailDbName)
If Maildb.IsOpen = True Then
'Already open for mail
Else
Maildb.OPENMAIL
End If

'Set up the new mail document
Set MailDoc = Maildb.CreateDocument
MailDoc.Form = "Memo"
If InStr(strRecipient, ",") > 0 Then
Dim strSendTo() As String
ReDim Preserve strSendTo(1 To 1)
strSendTo(1) = GetItemFromList(strRecipient)
Do Until strRecipient = ""
ReDim Preserve strSendTo(1 To UBound(strSendTo) + 1)
strSendTo(UBound(strSendTo)) = GetItemFromList(strRecipient)
Loop
MailDoc.sendto = strSendTo
Else
MailDoc.sendto = strRecipient
End If

If InStr(strCCTo, ",") > 0 Then
ReDim Preserve strCopyTo(1 To 1)
strCopyTo(1) = GetItemFromList(strCCTo)
Do Until strCCTo = ""
ReDim Preserve strCopyTo(1 To UBound(strCopyTo) + 1)
strCopyTo(UBound(strCopyTo)) = GetItemFromList(strCCTo)
Loop
MailDoc.CopyTo = strCopyTo
Else
MailDoc.CopyTo = strCCTo
End If

MailDoc.Subject = strSubject
MailDoc.Body = strBodyText
MailDoc.SAVEMESSAGEONSEND = blnSave

'Set up the embedded object and attachment and attach it
Do Until strAttachment = ""
intCnt = intCnt + 1
strAttach = GetItemFromList(strAttachment)
If Dir(strAttach) <> "" Then
Set AttachME = MailDoc.CreateRichTextItem("strAttach" & intCnt)
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", strAttach,
"strAttach" & intCnt)
End If
Loop

'Send the document
MailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items
folder
MailDoc.SEND 0

SendNotesMailError:
MsgBox "An error occured sending the mail message via Lotus Notes.
Error " & Err & ": " & Error(Err), vbExclamation, gstrAppName
Resume SendNotesMailExit

End Sub

Sandy Hayman
AA Absolute Access - ACT, Australia
 
Many thanks Sandy for your complete response.
In the meantime I have found something much easier for me. I have just
changed in my Internet Options (programs) the default mail program: Lotus
Notes instead of Outlook.
But I have one problem : when I click an Email Address, this opens a new
memo in my Lotus Notes with the clicked Email Address, but when I click a
second or third Email Address, I do have a new memo in Lotus Notes but the
Email Address is not complete. I should quit the form to be able to have the
complete Email Address.
It seems that I need to update the form or addresses.
Thank you for your reply
 
Back
Top