• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 219
  • Last Modified:

Word macro to send an email to a mailbox on the mail server

We are using Lotus Notes R5. We receive our pay slips in a single Word document.  I have been tasked with simplifying the distribution of the payslips to th individual employees.  I have written a Word macro which seperates th slips into individual Word documents and the documets are saved as the the employee's short-email-address.doc (ex JohnS.doc) .  The files ase saved on the mail server.  How can I best have an agent send these payslips to the individual recipients?  

For example, would it be possible for the Word macro to send an email to a mailbox on the mail server which would trigger the agent to run when the email arrives?
All suggestions will be appreciated.
0
witgrefe
Asked:
witgrefe
  • 2
2 Solutions
 
qwaleteeCommented:
Better to have the Word macro just send teh payslips directly, rather than depositing them on the server and then having an agent do them.  Here's a simple function in VBA to do this:

Sub SendSlip ( notesSession , shortName As String , attachmentFilePath As String)
    Set dbDir = notesSession.getDbDirectory()
    Set myMail = dbDir.openMailFile()
    Set msg = myMail.CreateDocument()
    msg.replaceItemValue "Form" , "Memo"
    msg.replaceItemValue "SendTo" , shortName
    msg.replaceItemValue "Subject" , "Pay stub enclosed"
    Set body = msg.createRichTextItem("Body")
    body.embedObject 1454 , "" , attachmentFilePath
    msg.send False
End Sub

Just pass it a notesSession onject, the short name string, and a string containing teh full path name of the file.

How to create a NotesSession?  Attach the TLB from the Notes directory to your VBA project, then...

Dim s as New Lotus.NotesSession
s.Initialize("your Notes password")

You can now pass --> s <-- as the first parameter.
0
 
witgrefeAuthor Commented:
Hello Qwaletee,

I presume you mean the notes32.tlb, but I not sure that I know how to attach it to the macro.  The macro is in a .dot template.  Does that make any difference?

Regards
0
 
yangshuhuaCommented:
It's domobj.tlb. in Lotus Notes data  folder on your local computer.

Sherry

0
 
witgrefeAuthor Commented:
Thanks Sherry,

my problem is that I do not know how to 'attach' it.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now