You'll need to make sure that your references to Notes are in order
(hint:
look on any modulemenubar for Tools ... References) then make sure the
one
for Notes is checked. Your command button code might look something like
this (Add error handling):
Sub cmdSendNotesMail_Click()
SendMail
End Sub
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
Do I put this in a command button code or somewhere else. I am a bit
of a
novice and have been trying to figure out how to do this for several
months.
All code I have been using i have found on the internet. I just need a
little help understanding how to input your code. Thanks.
--
ELL
:
I have put in code to auto email using my lotus notes. Everything
works
(when clicked, lotus notes opens, attachment goes in, "To" and
"Subject"
fields fills out) except it will not automatically send the email.
I
put
in
"false" but that is not working. I wrote a macro and put in "no"
for
edit
message and still it will not automatically send the email. I have
to
click
on the send button. Is there more code I need to make Lotus Notes
send
without having to click on the send button?
I didn't originally write this code, but I adapted it several years
ago
to
send email and it worked just fine:
Global NotesSession As Object
Global NotesMaildb As Object
Global NotesMailDoc As Object
Global NotesFileAttachment As Object
Global NotesRichTextItem As Object
Global NotesItem As Object
' Initialize Notes Objects
Set NotesSession = CreateObject("Notes.NotesSession")
'Set NotesMaildb = NotesSession.GetDatabase("SIN_MAIL_01",
"mail\KVENUGOP.nsf")
Set NotesMaildb = NotesSession.GetDatabase("", "")
NotesMaildb.OpenMail
'Put the following in a subroutine:
Sub SendMail()
On Error GoTo Error_Handler
Set NotesMailDoc = NotesMaildb.CreateDocument
'Function syntax - EmbedObject(type, Class, source, [name])
'Set NotesFileAttachment = NotesRichTextItem.EmbedObject(0, "",
"C:\Test.htm")
NotesMailDoc.SaveMessageOnSend = True
NotesMailDoc.SendTo = "(e-mail address removed)"
NotesMailDoc.from = NotesSession.UserName
NotesMailDoc.Subject = "Test mail"
NotesMailDoc.Body = "This is a sample mail to check the OLE
functionality to send mail. _
This mail has a file attached."
NotesMailDoc.Send
Exit_Here:
Set NotesView = Nothing
Set NotesMaildb = Nothing
Set NotesSession = Nothing
Set NotesMailDoc = Nothing
Set NotesFileAttachment = Nothing
Set NotesRichTextItem = Nothing
Exit Sub
Error_Handler:
MsgBox "This email was not sent", vbOKOnly, "Error"
Resume Exit_Here
End Sub
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com