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.