Emailing from a word form via notes

W

WP

Can you guys tell me why my code stops??
I have created a button on my form to email this doc after they save
it but when I click the email button its stops and highlights the
Private Const and says invalid attribute in sub or function

Private Sub CommandButton2_Click()

Private Const EMBED_ATTACHMENT As Integer = 1454

Private Sub SendMailWithAttachment()

Dim s As Object
Dim db As Object
Dim doc As Object
Dim rtItem As Object

Dim Server As String, Database As String
Dim strError As String

Screen.MousePointer = vbHourglass

'Here's the server name and database name
Server = "nsxx01"
Database = "nsxx01\xxwp.nsf"

' start up Lotus Notes and get object handle

Set s = CreateObject("Notes.NotesSession")

Set db = s.GETDATABASE(Server, Database)

On Error GoTo ErrorLogon
' See if user is logged on yet;
' if not, the error handler will
' kick in!
Set doc = db.CREATEDOCUMENT
On Error GoTo 0

doc.Form = "Memo"

'Send an EMail to myself
doc.SendTo = "xxwp@..."
doc.Subject = "Literature Request"
' this will build the text part of your mail message

Set rtItem = doc.CREATERICHTEXTITEM("Body")
Call rtItem.APPENDTEXT("A literature request")
Call rtItem.ADDNEWLINE(1)

'Attach a document!
Call rtItem.EmbedObject
(EMBED_ATTACHMENT, "", "T:\Docs\word\Litrequest.doc")

Call doc.SEND(False) 'Make sure this parameter stays false

' set all object handles to nothing to release memory
Set doc = Nothing
Set db = Nothing
Set s = Nothing
Set rtItem = Nothing

Screen.MousePointer = vbDefault
MsgBox "Mail has been sent!", vbInformation

Exit Sub

ErrorLogon:
If Err.Number = 7063 Then
MsgBox "Please login to Lotus Notes first!", vbCritical
Set doc = Nothing
Set db = Nothing
Set s = Nothing
Set rtItem = Nothing
Screen.MousePointer = vbDefault
Exit Sub
Else
strError = "An Error has occurred on your system:" & vbCrLf
strError = strError & "Err. Number: " & Err.Number & vbCrLf
strError = strError & "Description: " & Err.Description
MsgBox strError, vbCritical
Set doc = Nothing
Set db = Nothing
Set s = Nothing
Set rtItem = Nothing
Screen.MousePointer = vbDefault
Exit Sub
End If

UserForm1.Hide

End Sub
 
S

Steve Rindsberg

Can you guys tell me why my code stops??
I have created a button on my form to email this doc after they save
it but when I click the email button its stops and highlights the
Private Const and says invalid attribute in sub or function

You can't define constants within a subroutine or function.
Move the const def to the top of the module, before any subs/functions.
 

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