By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,054 Members | 1,635 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,054 IT Pros & Developers. It's quick & easy.

Emailing from MS Access XP using Lotus Domino Objects

P: n/a
I discovered, with great excitement, this article
http://www.davison.uk.net/vb2notes.asp when researching methods for
emailing from Access via Notes. Unfortunatly, when I run this I get a
Run-time error. When I run it on an XP machine it crashes, but on an
NT box it just generates an unknown error, handled by the error
handler. I have debugged and stepped through the code and have
narrowed the issue to the point at which the NotesMailMemo class tries
to establish a Notes.Session in the .SEND method.

I have referenced the Lotus Domino Odjects tlb file as explained.

I have pasted in the code I am trying to use to call this method, and
a copy of the class file provided on the website:

'************************************************* ****************************
'
' Notes Mail Memo Class
'
' This program is free software; you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation; either version 2 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program; if not, write to the Free Software
' Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
'
'
' Created: 1/12/98
' by: Darren Davison (da****@davison.uk.net)
' platform: VBA in Office97, VB4,5,6 (class file), or any platform
' supporting Automation (compiled DLL)
' use: send LNotes mail with/out attachments from VB/VBA.
' Error handling is basic and needs fleshing out.
'

'
' Notes:
' Add this file to a project, then declare & use variables in
' your code as in the following eg..
'
' Dim MyMemo As New NotesMailMemo
'
' With MyMemo
' 'SendTo is required, all the others are optional.
' .SendTo = "Darren Davison"
' .cc = "SomeGroup"
' .bcc = "SomeOtherGroup"
' .Priority = "H" 'high
' .Subject = "Hello!"
' .Body = "Here's a couple of files..."
' .Attach "c:\temp\myfile.txt"
' .Attach "c:\temp\myfile2.txt"
' .Signed = True
' .Encrypted = False
' End With
'
' MyMemo.Send
'
'
'
'
' Modification History
'
' Date By Notes
' -------------------------------------------------------------------------
' 10/3/99 DD Added comments since several people
' requested a copy of this file. Please
' note - this file may be freely distributed
' ONLY if it is not in any way amended. The
' author accepts no responsibility for any
' damage arising from the use or misuse of
' this code and is not available for support.
'
' 8/4/99 DD Amended class constructor to set values
' in class variables, rather than it's own
' properties.
'
' 2/9/99 DD Amended layout of this file according to
_template
' class
'
' 21/09/99 DD Amended Priority Let to read first char of
param, and
' linked 'Importance' stamp to priority.
'
' Amended Send method to add blank lines before
attach-
' ments.
'
' Added SigFile property to append to body text.
'
' 01/03/00 DD Changed references to Domino objects now that
Domino
' supports early binding (since 5.02b). The
project
' file that contains this class will need to
reference
' the library 'Lotus Domino Objects'
(domobj.tlb)
'
' 16/08/00 DD Fixed a couple of minor bugs.
'
' 15/09/00 DD Made it work with R5 (properly). Added COM
functio-
' nality for passing name/password on a server.
'
' 01/08/01 DD Tidied upa and fixed minor potential bug in
send
' method.
'
' 04/09/02 DD Minor bugfix in Priority property.
'
'************************************************* ****************************

' ----------------------------------------------------------------------------
' Module/Class options
' ----------------------------------------------------------------------------
Option Explicit
' ----------------------------------------------------------------------------
' Constants As Type = Value
' ----------------------------------------------------------------------------
Private Const EMBED_ATTACHMENT As Integer = 1454
Private Const MAIL_BOX As String = "mail.box"
Private Const DEFAULT_FORM As String = "Memo"
Private Const VB2NOTES_ERROR_SEND As Integer = 101
Private Const CMP_SRCNAME As String = "VB2Notes"
' ----------------------------------------------------------------------------
' Class Variables As Type
' ----------------------------------------------------------------------------
Private sAttachments() As String
Private sSendTo As String
Private sCC As String
Private sBcc As String
Private sBody As String
Private sSubject As String
Private sPriority As String
Private sImportance As String
Private bEncrypted As Boolean
Private bSigned As Boolean
Private sForm As String
Private sSigFile As String
' ----------------------------------------------------------------------------
' Forward Declarations / DLL Functions
' ----------------------------------------------------------------------------

' ----------------------------------------------------------------------------
' Property Let / Get
' ----------------------------------------------------------------------------
Public Property Let SendTo(strSendTo As String)
sSendTo = strSendTo
End Property
Public Property Get SendTo() As String
SendTo = sSendTo
End Property

Public Property Let CC(strCC As String)
sCC = strCC
End Property
Public Property Get CC() As String
CC = sCC
End Property

Public Property Let Bcc(strBcc As String)
sBcc = strBcc
End Property
Public Property Get Bcc() As String
Bcc = sBcc
End Property

Public Property Let Body(strBody As String)
sBody = strBody
End Property
Public Property Get Body() As String
Body = sBody
End Property

Public Property Let Subject(strSubject As String)
sSubject = strSubject
End Property
Public Property Get Subject() As String
Subject = sSubject
End Property

Public Property Let Priority(strPriority As String)
Select Case UCase(Left(strPriority, 1))
Case "H"
sPriority = "H"
sImportance = "1"

Case "L"
sPriority = "L"
sImportance = "3"

Case Else 'including "N"
sPriority = "N"
sImportance = "2"
End Select
End Property
Public Property Get Priority() As String
Priority = sPriority
End Property

Public Property Let Form(strForm As String)
sForm = strForm
End Property
Public Property Get Form() As String
Form = sForm
End Property

Public Property Let Encrypted(boolEncrypt As Boolean)
bEncrypted = boolEncrypt
End Property
Public Property Get Encrypted() As Boolean
Encrypted = bEncrypted
End Property

Public Property Let Signed(boolSign As Boolean)
bSigned = boolSign
End Property
Public Property Get Signed() As Boolean
Signed = bSigned
End Property

'*
'read-only property returns comma-separated list of
'files that are to be attached. Corresponding
'method is the public sub Attach.
'*
Public Property Get Attachments() As String

Dim f%

For f = 0 To UBound(sAttachments)
If sAttachments(f) <> "" Then Attachments = Attachments + ","
+ sAttachments(f)
Next f

'remove first comma
If Attachments <> "" Then
Attachments = Right(Attachments, Len(Attachments) - 1)
End If

End Property

Public Property Let SigFile(strSigFile As String)
'allow not file exists
sSigFile = strSigFile
End Property
Public Property Get SigFile() As String
SigFile = sSigFile
End Property

' ----------------------------------------------------------------------------
' Class Methods
' ----------------------------------------------------------------------------
Private Sub Class_Initialize()

'set default properties
sForm = DEFAULT_FORM
sCC = ""
sBcc = ""
bEncrypted = False
bSigned = False
sPriority = "N"
sImportance = "2"
ReDim Preserve sAttachments(0)

End Sub
' ----------------------------------------------------------------------------
' Methods
' ----------------------------------------------------------------------------

'*
'Files which were listed as attachments that don't
'exist at the time this function
'is called are simply ignored - no error raised.
'*
Public Sub Send(Optional sNotesUserName, Optional sNotesPassword)

On Error GoTo errSend

Dim s As NotesSession, mailDb As NotesDatabase
Dim mailDoc As NotesDocument, rtItem As NotesRichTextItem
Dim f%, fileNo%, sLine$

Set s = New NotesSession
If IsMissing(sNotesUserName) Then
'expect that a client or server is running with a compromised
password
s.Initialize
Else
'server only - not client
If IsMissing(sNotesPassword) Then
s.InitializeUsingNotesUserName CStr(sNotesUserName)
Else
s.InitializeUsingNotesUserName CStr(sNotesUserName),
CStr(sNotesPassword)
End If
End If
Set mailDb = s.GetDatabase("", MAIL_BOX)
Set mailDoc = mailDb.CreateDocument

With mailDoc
.AppendItemValue "Form", sForm
.AppendItemValue "SendTo", sSendTo
.AppendItemValue "CopyTo", sCC
.AppendItemValue "BlindCopyTo", sBcc
.AppendItemValue "Subject", sSubject
.AppendItemValue "DeliveryPriority", sPriority
.AppendItemValue "Importance", sImportance
.AppendItemValue "EncryptOnSend", bEncrypted
If bSigned Then Call .Sign

Set rtItem = .CreateRichTextItem("Body")
rtItem.AppendText sBody
rtItem.AddNewLine 2

'attempt to write sigfile
fileNo = FreeFile
Open sSigFile For Input As #fileNo

While Not EOF(fileNo)
Line Input #fileNo, sLine
rtItem.AppendText sLine
rtItem.AddNewLine 1
DoEvents
Wend

rtItem.AddNewLine 2

resAttachments:
For f = 1 To UBound(sAttachments())
If Dir(sAttachments(f)) <> "" Then
Call rtItem.EmbedObject(EMBED_ATTACHMENT, "",
sAttachments(f))
End If
Next f

Call .Send(False)

End With
resExit:
On Error Resume Next
Close
Set mailDoc = Nothing
Set mailDb = Nothing
Set s = Nothing
Exit Sub

errSend:
Dim errNo As Long
errNo = Err.Number

Select Case errNo
Case 52 To 76 'file/path/IO errors
Resume resAttachments

Case Else
're-raise error
Err.Raise VB2NOTES_ERROR_SEND + vbObjectError, _
CMP_SRCNAME, "Unknown error sending mail memo."
End Select

Resume resExit

End Sub

'*
'add to list of attachments waiting. Any string is accepted, but
'files will be checked when memo is sent.
'*
Public Sub Attach(strFileToAttach As String)

Dim iTotal%

iTotal = UBound(sAttachments())

ReDim Preserve sAttachments(iTotal + 1)
sAttachments(iTotal + 1) = strFileToAttach

End Sub

'************************************************* ****************************
Option Compare Database

Public Sub SendMail()

' create a new notes mail
' by setting a variable
' which will reference our
' class file.
Dim oMemo As NotesMailMemo

' instantiate it (this could
' have been done above equally well
' by saying Dim oMemo As New NotesMailMemo)
Set oMemo = New NotesMailMemo

' let's set some properties
' of our new mail
With oMemo

' SendTo is the only property
' that is actually required
' to send a valid notes mail.
' All of the others after
' this are entirely discretionary.
' Group names and internet
' addresses will also work in
' the SendTo, cc and bcc fields
' if your domino server / notes
' client is setup correctly.
.SendTo = "recipient/group/site"

' optionally..
.CC = ""

.Bcc = ""

.Subject = "Test"

' the body field here is
' created from a String and not the
' rich-text format used by the
' notes client by default. If you
' need additional functionality here,
' you will have to amend the
' class file
.Body = "Text message"
' the signature file allows
' any text file to be appended to the
' body of the mail
.SigFile = ""

' couple of notes options
.Signed = False
.Encrypted = False
.Priority = "H" ' or "L" or "N"

' file attachments - you can call
' this method as often as you like
' for multiple files.
.Attach ""
.Attach ""

' deliver it..
.Send "username/group/site", "mypassword"
End With

End Sub
Nov 12 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Colin Anderson wrote:
I discovered, with great excitement, this article
http://www.davison.uk.net/vb2notes.asp when researching methods for


I get a 404 error there, however there is this site
http://www.fabalou.com/VBandVBA/lotusnotesmail.asp the code on there
works (presumably as long as you have notes installed hehe).

--
Error reading sig - A)bort R)etry I)nfluence with large hammer
Nov 12 '05 #2

P: n/a
TR
Colin Anderson wrote:
I discovered, with great excitement, this article
http://www.davison.uk.net/vb2notes.asp when researching methods for
emailing from Access via Notes. Unfortunatly, when I run this I get a
Run-time error. When I run it on an XP machine it crashes, but on an
NT box it just generates an unknown error, handled by the error
handler. I have debugged and stepped through the code and have
narrowed the issue to the point at which the NotesMailMemo class tries
to establish a Notes.Session in the .SEND method.


I have not had any success using COM, so I have used OLE.
Here is a rudimentary class for sending an email using Lotus from access xp and/or
vb, and an example of use.
example:

Public Function TestNewClass()
Dim oEmail As clsEmailMessage
Set oEmail = New clsEmailMessage
oEmail.AddRecipient "ad*****@internet.net", recipTo
oEmail.AddRecipient "ad******@internet.net", recipTo
oEmail.AddAttachment "C:\Temp\Test.xls"
oEmail.AddAttachment "C:\Temp\Test.gif"
oEmail.SendEmail "Testing Email Class", "This is the body", True
Set oEmail = Nothing
End Function

Here is the code for clsEmailMessage:

'**************************CLASS CODE **************
Option Compare Database
Option Explicit
'creates and sends email using lotus notes.
'does not require notes to be running (it will start a session if needed).
'does not require references in the project
'uses OLE not com, so objects are declared as simple objects
'the declares below are for using COM, but this may require some
'additional configuration to work.
'Dim mobjNotesDB As NotesDatabase
'Dim mobjNotesMessage As NotesDocument
'Dim mobjNotesRTItem As NotesRichTextItem
'Dim mobjNotesSession As notessession
Dim mobjNotesSession As Object 'lotus notes session
Dim mobjNotesMessage As Object 'a notesdocument object (the email message)
Dim mobjNotesDB As Object 'a notes db object
Dim mobjNotesRTItem As Object 'a notes tich text object

'notes constant for attaching file
Const EMBED_ATTACHMENT = 1454

Public Enum RecipTypes
recipTo = 1
recipCc = 2
End Enum

Private Sub Class_Initialize()
Set mobjNotesSession = CreateObject("Notes.Notessession")
Set mobjNotesDB = mobjNotesSession.GetDatabase("", "")
Call mobjNotesDB.openmail
' make new mail message
Set mobjNotesMessage = mobjNotesDB.CreateDocument
'create the body
Set mobjNotesRTItem = mobjNotesMessage.CreateRichTextItem("Body")
End Sub

Private Sub Class_Terminate()
Set mobjNotesSession = Nothing
Set mobjNotesMessage = Nothing
Set mobjNotesDB = Nothing
Set mobjNotesRTItem = Nothing
End Sub

Public Sub AddRecipient(strName As String, intType As RecipTypes)
Dim intNextSemiColon As Integer
Dim intLastSemiColon As Integer
Dim strOneAddress As String
Dim j As Integer
Dim blnLastAddress As Boolean

'If the passed contact has a semi-colon, split into multipe contacts
If InStr(1, strName, ";") > 0 Then
intLastSemiColon = 1
intNextSemiColon = 0
blnLastAddress = False
For j = 1 To Len(strName)
intNextSemiColon = InStr(intLastSemiColon, strName, ";")
If intNextSemiColon = 0 Then
blnLastAddress = True
strOneAddress = Mid(strName, intLastSemiColon, Len(strName))
Else
strOneAddress = Mid(strName, intLastSemiColon, intNextSemiColon - 1)
intLastSemiColon = intNextSemiColon + 1
End If
If intType = recipTo Then
If mobjNotesMessage.HasItem("SendTo") Then
Call mobjNotesMessage.AppendItemValue("Sendto", strOneAddress)
Else
Call mobjNotesMessage.ReplaceItemValue("Sendto", strOneAddress)
End If
ElseIf intType = recipCc Then
If mobjNotesMessage.HasItem("Copyto") Then
Call mobjNotesMessage.AppendItemValue("Copyto", strOneAddress)
Else
Call mobjNotesMessage.ReplaceItemValue("Copyto", strOneAddress)
End If
End If
If blnLastAddress = True Then Exit For
Next j

'Otherwise, just add one name
Else
If intType = recipTo Then
If mobjNotesMessage.HasItem("SendTo") Then
Call mobjNotesMessage.AppendItemValue("Sendto", strName)
Else
Call mobjNotesMessage.ReplaceItemValue("Sendto", strName)
End If
ElseIf intType = recipCc Then
If mobjNotesMessage.HasItem("Copyto") Then
Call mobjNotesMessage.AppendItemValue("Copyto", strName)
Else
Call mobjNotesMessage.ReplaceItemValue("Copyto", strName)
End If
End If
End If
End Sub

Public Sub AddAttachment(strFilePath As String, Optional vName As Variant)
Dim strName As String

If IsNull(vName) Or IsMissing(vName) Then
strName = strFilePath
Else
strName = vName & ""
End If
mobjNotesRTItem.EmbedObject EMBED_ATTACHMENT, "", strFilePath, strName
End Sub

Public Sub SendEmail(strSubject As String, strText As String, blnPreview As
Boolean)
Call mobjNotesMessage.ReplaceItemValue("Subject", strSubject)
Call mobjNotesRTItem.AddNewLine(2)
Call mobjNotesRTItem.AppendText(strText)
mobjNotesMessage.SaveMessageOnSend = True
If blnPreview = False Then
Call mobjNotesMessage.Send(False)
Else
Call mobjNotesMessage.Save(True, False)
End If
End Sub
'***************END CLASS CODE ***************************
Nov 12 '05 #3

P: n/a
Here is some code I wrote in Excel to email via Lotus Notes. This has
been working fine for me for a couple of years (Lotus Notes Version R5).
It also works in Access.

Note:

p_SendTo() is a string array of email addresses to send email to. You
can send multiple email addresses, or even groups. Also, p_SendTo() is
an array for attachments. I send Excel workbooks, but you can attach
pretty much anything. Just make sure you have a reference to Lotus
Domino Objects (not Lotus Notes Automation classes). This code only
works with the Domino Library (and Domino R5 Servers).

Sub SendNotesMail(p_SendTo() As String, p_Subject As String, p_Body As
String, p_Path() As String, p_NotesPassword As String)
Dim n_Session As New NotesSession
Dim n_dir As NotesDbDirectory
Dim n_db As NotesDatabase
Dim n_doc As NotesDocument
Dim n_object As NotesEmbeddedObject
Dim n_rtitem As NotesRichTextItem
Dim i As Integer
On Error GoTo Errlbl
Call n_Session.Initialize(p_NotesPassword)

Set n_dir = n_Session.GetDbDirectory("")
Set n_db = n_dir.OpenMailDatabase
Set n_doc = n_db.CreateDocument
Call n_doc.AppendItemValue("Form", "Memo")

Call n_doc.AppendItemValue("SendTo", p_SendTo())
Call n_doc.AppendItemValue("Subject", p_Subject)
'Call n_doc.AppendItemValue("posteddate", Now())

Set n_rtitem = n_doc.CreateRichTextItem("Body")
n_rtitem.AppendText (p_Body & vbCrLf & vbCrLf)
For i = 0 To UBound(p_Path)
Set n_object = n_rtitem.EmbedObject(EMBED_ATTACHMENT, "", p_Path(i))
Next i
n_doc.SaveMessageOnSend = True
Call n_doc.Send(False)

Set n_db = Nothing
Set n_Session = Nothing
MsgBox "Email has been sent"
Exit Sub
Errlbl:
MsgBox Err.Description
End Sub

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #4

P: n/a
Thanks TR, I have a couple of problems with this code that I am
hoping you can help with:

1. The message is not sending but instead is saved in the Drafts
folder.

2. If the Notes client is not running, it does start an instance of
the client. However, the UI in the instance it creates does not open
to the users home database (we use a corporate portal db as the home
db). This is confusing for the users. Is there a way that the client
can be 'killed' after the mail has been sent? Also, is there a way to
send the Username/password so the user is not prompted, then stop the
UI from being displayed? Basically, I want to send the email via
Notes with as little interation or knowledge of the user.

Thanks a lot for your help.

TR <t_NoSpam_redick@Mind_NoSpam_spring.com> wrote in message news:<40A2845F.FB8DE786@Mind_NoSpam_spring.com>...
Colin Anderson wrote:
I discovered, with great excitement, this article
http://www.davison.uk.net/vb2notes.asp when researching methods for
emailing from Access via Notes. Unfortunatly, when I run this I get a
Run-time error. When I run it on an XP machine it crashes, but on an
NT box it just generates an unknown error, handled by the error
handler. I have debugged and stepped through the code and have
narrowed the issue to the point at which the NotesMailMemo class tries
to establish a Notes.Session in the .SEND method.


I have not had any success using COM, so I have used OLE.
Here is a rudimentary class for sending an email using Lotus from access xp and/or
vb, and an example of use.
example:

Public Function TestNewClass()
Dim oEmail As clsEmailMessage
Set oEmail = New clsEmailMessage
oEmail.AddRecipient "ad*****@internet.net", recipTo
oEmail.AddRecipient "ad******@internet.net", recipTo
oEmail.AddAttachment "C:\Temp\Test.xls"
oEmail.AddAttachment "C:\Temp\Test.gif"
oEmail.SendEmail "Testing Email Class", "This is the body", True
Set oEmail = Nothing
End Function

Here is the code for clsEmailMessage:

'**************************CLASS CODE **************
Option Compare Database
Option Explicit
'creates and sends email using lotus notes.
'does not require notes to be running (it will start a session if needed).
'does not require references in the project
'uses OLE not com, so objects are declared as simple objects
'the declares below are for using COM, but this may require some
'additional configuration to work.
'Dim mobjNotesDB As NotesDatabase
'Dim mobjNotesMessage As NotesDocument
'Dim mobjNotesRTItem As NotesRichTextItem
'Dim mobjNotesSession As notessession
Dim mobjNotesSession As Object 'lotus notes session
Dim mobjNotesMessage As Object 'a notesdocument object (the email message)
Dim mobjNotesDB As Object 'a notes db object
Dim mobjNotesRTItem As Object 'a notes tich text object

'notes constant for attaching file
Const EMBED_ATTACHMENT = 1454

Public Enum RecipTypes
recipTo = 1
recipCc = 2
End Enum

Private Sub Class_Initialize()
Set mobjNotesSession = CreateObject("Notes.Notessession")
Set mobjNotesDB = mobjNotesSession.GetDatabase("", "")
Call mobjNotesDB.openmail
' make new mail message
Set mobjNotesMessage = mobjNotesDB.CreateDocument
'create the body
Set mobjNotesRTItem = mobjNotesMessage.CreateRichTextItem("Body")
End Sub

Private Sub Class_Terminate()
Set mobjNotesSession = Nothing
Set mobjNotesMessage = Nothing
Set mobjNotesDB = Nothing
Set mobjNotesRTItem = Nothing
End Sub

Public Sub AddRecipient(strName As String, intType As RecipTypes)
Dim intNextSemiColon As Integer
Dim intLastSemiColon As Integer
Dim strOneAddress As String
Dim j As Integer
Dim blnLastAddress As Boolean

'If the passed contact has a semi-colon, split into multipe contacts
If InStr(1, strName, ";") > 0 Then
intLastSemiColon = 1
intNextSemiColon = 0
blnLastAddress = False
For j = 1 To Len(strName)
intNextSemiColon = InStr(intLastSemiColon, strName, ";")
If intNextSemiColon = 0 Then
blnLastAddress = True
strOneAddress = Mid(strName, intLastSemiColon, Len(strName))
Else
strOneAddress = Mid(strName, intLastSemiColon, intNextSemiColon - 1)
intLastSemiColon = intNextSemiColon + 1
End If
If intType = recipTo Then
If mobjNotesMessage.HasItem("SendTo") Then
Call mobjNotesMessage.AppendItemValue("Sendto", strOneAddress)
Else
Call mobjNotesMessage.ReplaceItemValue("Sendto", strOneAddress)
End If
ElseIf intType = recipCc Then
If mobjNotesMessage.HasItem("Copyto") Then
Call mobjNotesMessage.AppendItemValue("Copyto", strOneAddress)
Else
Call mobjNotesMessage.ReplaceItemValue("Copyto", strOneAddress)
End If
End If
If blnLastAddress = True Then Exit For
Next j

'Otherwise, just add one name
Else
If intType = recipTo Then
If mobjNotesMessage.HasItem("SendTo") Then
Call mobjNotesMessage.AppendItemValue("Sendto", strName)
Else
Call mobjNotesMessage.ReplaceItemValue("Sendto", strName)
End If
ElseIf intType = recipCc Then
If mobjNotesMessage.HasItem("Copyto") Then
Call mobjNotesMessage.AppendItemValue("Copyto", strName)
Else
Call mobjNotesMessage.ReplaceItemValue("Copyto", strName)
End If
End If
End If
End Sub

Public Sub AddAttachment(strFilePath As String, Optional vName As Variant)
Dim strName As String

If IsNull(vName) Or IsMissing(vName) Then
strName = strFilePath
Else
strName = vName & ""
End If
mobjNotesRTItem.EmbedObject EMBED_ATTACHMENT, "", strFilePath, strName
End Sub

Public Sub SendEmail(strSubject As String, strText As String, blnPreview As
Boolean)
Call mobjNotesMessage.ReplaceItemValue("Subject", strSubject)
Call mobjNotesRTItem.AddNewLine(2)
Call mobjNotesRTItem.AppendText(strText)
mobjNotesMessage.SaveMessageOnSend = True
If blnPreview = False Then
Call mobjNotesMessage.Send(False)
Else
Call mobjNotesMessage.Save(True, False)
End If
End Sub
'***************END CLASS CODE ***************************

Nov 12 '05 #5

P: n/a
TR
Hi Colin,
To send immediately, change the blnPreview parameter to false when you call the SendEmail method:
oEmail.SendEmail "Testing Email Class", "This is the body", False

As to the other problem, I may not be much help. Using Lotus is new to me, and I am still learning. The class works
fine with our configuration (provided the users password is the same as their windows password), but I am not very
knowledgeable about the notes paradigm of databases, servers, etc.. You may be able to use additional arguments
when creating the session or calling getdatabase, but I'm not sure what you would need. If you disable the OLE
declarations, enable the COM declarations, and reference the Lotus Domino Objects, you can view the Intellisense
options for the various methods in the VBE window.
But I always have an error trying to use com, so I always switch back to the OLE methods to actually use the code.

Colin Anderson wrote:
Thanks TR, I have a couple of problems with this code that I am
hoping you can help with:

1. The message is not sending but instead is saved in the Drafts
folder.

2. If the Notes client is not running, it does start an instance of
the client. However, the UI in the instance it creates does not open
to the users home database (we use a corporate portal db as the home
db). This is confusing for the users. Is there a way that the client
can be 'killed' after the mail has been sent? Also, is there a way to
send the Username/password so the user is not prompted, then stop the
UI from being displayed? Basically, I want to send the email via
Notes with as little interation or knowledge of the user.

Thanks a lot for your help.


Nov 12 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.