FREE tutorial,solution,RSS Feeds on Operating Systems, Programming, Web Development, Applications, Databases, Networking, Hardware, Security, SEO Free Expertsforge Membership
Join us as Moderator
Submit Article to Expertsforge.com Submit Article My Expertsforge
 
RSS Feeds, Help Help RSS Feeds
bannertop
 

Lotus Notes/Domino Tutorial: Sending an Automated Lotus Notes Mail with attachment using VBS and Windows Task Scheduler

jawahar
9/10/2007 7:48:07 AM, Views: 792
The following tutorial and code can be used to send scheduled automated mail with attachment using Lotus Notes and VBS and Windows Scheduler.

Creating the VB Script for Sending Lotus Notes Mail:

1. Open Notepad or your favourite text editor.
2. Copy and Paste the below code into the notepad document.

Dim recep,ccRecipient
Redim recep(15)
Redim ccRecipient(10)

Set Session1 = CreateObject("Notes.NotesSession")
UserName = Session1.UserName
MailDbName = "Mail\yourmaildbname.nsf" 'You can find this if you right click your notes mail box and database>properties
Set Maildb = Session1.GETDATABASE("yourmailserver", MailDbName) 'You can find this if you right click your notes mail box and database>properties
If Maildb.IsOpen = True Then
Else
Maildb.OPENMAIL
End If
attachment1 = "C:\attachment_file.txt"
Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.form = "Memo"
recep(0)="yourusername/yourcompany/yourcountry" 'Just an example
recep(1)="yourusername/yourcompany/yourcountry" 'Just an example

ccRecipient(1)="yourusername/yourcompany/yourcountry" 'Just an example

change it as per the recepient user id
subj = "Test Mail Subject"
mailbody = "Test Mail Body"
MailDoc.sendto = recep
MailDoc.CopyTo = ccRecipient
MailDoc.Subject = subj
MailDoc.Body = mailbody
MailDoc.SaveMessageOnSend = True
If attachment1 <> "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM("attachment1")
Set EmbedObj1 = AttachME.embedobject(1454, "attachment1", attachment1, "")
End If
Call MailDoc.Send(False)
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session1 = Nothing
Set EmbedObj1 = Nothing


3. Save the file as mymail.vbs (or the name which you opt for) in C: drive(for example)

Scheduling the Automated Mail Task:

1. Select Start>Programs>Accessories>System Tools>Scheduled Tasks
2. Double Click "Add Scheduled Task" in the Scheduled Tasks Window
3. Press Next, Click Browse button and select the mymail.vbs file that we saved previously.
4. Select the frequency, In this case I selected Daily. Click Next.
5. Enter the time and Start Date and press next
6. Enter the Windows Username, password, Press Next
7. Press Finish.
8. Windows will automatically execute the file which inturn sends the lotus notes mail.
Next Steps:
Add this Tutorial to:
Blink Blink del.icio.ous Del.icio.us Digg Digg
Fark Fark Furl Furl Google Google
Reddit Reddit Simpy Simpy Spurl Spurl
Technorati Technorati Windows Live Win Live Yahoo Yahoo
Rate Me!
Not Yet Rated!
Rate:
Send Private MessageSend Message
Signup / Login To View the Solution or Provide Comments
Post Comment/Solution
Comment:*
        (Link Rules) 
  Use : [bold] for <b>; [/bold] for </b>; [italic] for <i>; [/italic] for </i>; [code] & [/code] for code
 
Categories
Options
Lotus Notes/Domino RSS Feed
Most Popular Tutorial
Most Popular Solution
No Records!
Top Rated
No Records!
Top Rankers
Overall
1. jawahar (250)
Yearly -2008
No Rankings!
Expertsforge Sponsors
bnrtop