Important alert: (current site time 4/20/2014 11:36:08 AM EDT)

VB icon

A++ Send Lotus Notes Email VBS Script

Submitted on: 4/29/2004 3:03:47 PM
By: Steven Jacobs 
Level: Advanced
User Rating: By 3 Users
Compatibility: VbScript (browser/client side)
Views: 28391
author picture
(About the author)
     Simple script to send a Lotus Notes email. Can be modified to automate tasks on the server.
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
' Name: A++ Send Lotus Notes Email VBS Script
' Description:Simple script to send a Lotus Notes email. Can be modified to automate tasks on the server.
' By: Steven Jacobs
'This code is copyrighted and has' limited warranties.Please see'for details.'**************************************

on error goto 0: sendLNMail()
dim s
dim db
dim doc
dim rtitem
dim subj
dim bdy
dim recips(2)
'File System Object Decs
dim fs
dim fName
dim path
sub sendLNMail()
On Error Resume Next
'Begin Error/Input Routines
'Created by Steven Jacobs
'Get subject...if no subject, exit sub
subj = inputbox("Please enter a subject for your mail memo.","Email Subject Text")
if subj = "" then
 msgbox "You need a subject"
 exit sub
end if
'Get body text...if no body text, exit sub
bdy = inputbox("Please enter text for your body mail memo.","Email Body Text")
if bdy = "" then
 msgbox "You need body text"
 exit sub
end if
set fs = createobject("Scripting.FileSystemObject")
if fs Is Nothing then
 msgbox "Could Not Create FileSystemObject",16,"File System Object Error."
 exit sub
end if 
fName = inputbox("Please enter the full path for the file","Enter Full Path To File","C:\")
if fName = "" then
 msgbox "Empty Path"
 exit sub
end if
path = fs.GetAbsolutePathName(fName)
if Not fs.FileExists(path) then
 msgbox "File does not exist in directory you specified"
end if 
'End Error/Input Routines
set s = createobject("Notes.NotesSession")
if s Is Nothing then
 msgbox "Could Not Create A Session Of Notes",16,"Notes Session Error."
 exit sub
end if 
'See if we can create the main object (session)
If Err.Number <> 0 Then
On Error GoTo 0
msgbox "Could not create session 'Lotus Notes' from object"
exit sub
end if 
set db = s.getdatabase(s.getenvironmentstring("MailServer",True),s.getenvironmentstring("Mailfile",true))
'See if we can a handle on the mail file
If Err.Number <> 0 Then
On Error GoTo 0
msgbox "Could find or get a handle on the mail file"
exit sub
end if
set doc = db.createdocument
set rtitem = doc.createrichtextitem("BODY")
recips(1) = ""
recips(2) - ""
with doc
.form = "Memo"
.subject = subj
.sendto = "<xxx>" 
.copyto = "<yyy>"
.body = bdy
.postdate = Date
end with
call rtitem.embedobject(1454,"",fName)
doc.visible = true
doc.send false
'if we made it this far, alert the user the mail memo has been created and sent
msgbox "You message has been created and sent." & chr(13) & "Thank you.",64,"Message Sent Notification."
end sub
sub endMe()
'clean objects/memory
set s = nothing
set db = nothing
set doc = nothing
set rtitem = nothing
set fs = nothing
end sub

Other 1 submission(s) by this author


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)

Other User Comments

10/1/2004 4:52:31 PM

I am trying to use your code in an VB code application but when I try and run the script I get an error
Could Not Create FileSystemObject. Do you have an suggestions why it is throwing an error.
(If this comment was disrespectful, please report it.)

7/30/2006 5:04:28 AMSap

this won't work. You can't create any objects using VBScript on a web server. It is client-side only and will do nothing to the person viewing the site. It can't create the object also because there isn't a FileSystemObject.exe hosted on the site.

I wish it was server side :( :(
(If this comment was disrespectful, please report it.)


Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)

To post feedback, first please login.