How to CALL procedures from the module

G

Guest

Hi:

I created a module titled "modSendEmail" as shown below. I tried to call it
in a command button using "txtSendEmail_Click" but it returns an error
"Object is required". What I've done wrong. Thanks in advance.


Public Sub txtSendEmail_Click()
On Error GoTo SendEmail_Err

Dim notesdb As Object
Dim notesdoc As Object
Dim notesrtf As Object
Dim notessession As Object
Dim strSupportEMail As String

strSupportEMail = [Forms]![frmAssignedTask]![txtEmail]

Set notessession = CreateObject("Notes.Notessession")
Set notesdb = notessession.GETDATABASE("", "")
Call notesdb.OPENMAIL
Rem make new mail message
Set notesdoc = notesdb.CREATEDOCUMENT
Call notesdoc.replaceitemvalue("Sendto", strSupportEMail)
Call notesdoc.replaceitemvalue("CopyTo", "(e-mail address removed)")
Call notesdoc.replaceitemvalue("Subject", "Outstanding Matters")
Set notesrtf = notesdoc.CREATERICHTEXTITEM("body")
Call notesrtf.appendtext("A new task has been assigned to you. Click the
attached file to view it.")
Call notesrtf.addnewline(2)
Rem attach Error Report doc
's = ActiveDocument.Path + "\" + ActiveDocument.Name
Call notesrtf.EMBEDOBJECT(1454, "", "G:\Outstanding Matters\Test
attachment.doc", "Test attachment")
Rem send message
Call notesdoc.send(False)
Set notessession = Nothing

SendEmail_Exit:
Exit Sub

SendEmail_Err:
MsgBox "No E-mail address was provided for " &
Form.frmAssignment.txtAssignee.Value
Resume SendEmail_Exit

End Sub
 
A

Allan Murphy

Why do you need a module?

Sub txtSendEmail_Click() is the Click event property of your command button
called txtSendEmail. You could include your code in the click event of your
button

If you wish to use your module rename it SendEmailTxt or some other name,
then on the click event of your button enter SendEmailTxt or the new name of
your module.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top