Exporting document to Word and attaching the same in a mail

Hi,

I’m developing a web application where in i need to write an agent which would export the current document to MS word and then attach the same to a mail and send it across to a mail box.

Can any body help me in achiveing the above. A script would be really helpfull.

Thanks & Regards,

Amit Thakur

Subject: Export to Word

Might be easier and smarter to do PDF instead of MS Word.

Not sure if the below code will help but it is what I found in my code store db

Export to Word (Lotus Script)

Code / Description

This script will export domino Data using lotus script to microsoft word. This example will retrieve notes.ini variables and send them to ms word and saves the file as text file.

On line wordobj.ActiveDocument.SaveAs “c:\stagingr6\notes.ini”,2

The 2 will save the file as text format. You can use the below numbers to save the file to a different format.

wdFormatDocument 0

wdFormatDOSText 4

wdFormatDOSTextLineBreaks 5

wdFormatEncodedText 7

wdFormatFilteredHTML 10

wdFormatHTML 8

wdFormatRTF 6

wdFormatTemplate 1

wdFormatText 2

wdFormatTextLineBreaks 3

wdFormatUnicodeText 7

wdFormatWebArchive 9

wdFormatXML 11

Usage / Example

'to prevent error for directory already created with mkdir line

On Error Resume Next

’ Initialize variables

Dim session As NotesSession

Dim curdb As NotesDatabase

Dim ClientDataPath As String

Dim IdFileOnClient As String

Dim idFileNewOnClient As String

Dim ClientLocationDoc As String

Dim ClientMailSrv As String

Dim ClientMailFile As String

Dim wordobj As Variant

'Get session and database

Set session = New NotesSession

Set curdb = session.CurrentDatabase

’ Get Client notes.ini information

ClientLocationDoc = session.GetEnvironmentString(“Location”,True)

ClientMailSrv = session.GetEnvironmentString(“MailServer”,True)

ClientMailFile = session.GetEnvironmentString(“MailFile”,True)

ClientDataPath = session.GetEnvironmentString(“Directory”,True)

IdFileOnClient = session.GetEnvironmentString(“KeyFilename”,True)

If Instr(idFileOnClient,"")<>0 Then

IdFileNewOnClient = Strrightback(IdFileOnClient,"")

Else

idFileNewOnClient = IdFileOnClient

End If

'Get hangle of word object

Set wordobj = CreateObject (“Word.Application”)

’ open document and show application

wordobj.Documents.Add

wordobj.Visible = True

wordobj.Activate

’ Add text to ms word

wordobj.selection.TypeText “[Notes]” & Chr(10)

wordobj.selection.TypeText “KitType=1” & Chr(10)

wordobj.selection.TypeText “SharedDataDirectory=C:\Documents and Settings\All Users\Application Data\Lotus\Notes\Data\Shared” & Chr(10)

wordobj.selection.TypeText “SharedDataDirectory=C:\Documents and Settings%username%\Application Data\Lotus\Notes\Data\Shared” & Chr(10)

wordobj.selection.TypeText “MailServer=” & ClientMailSrv &Chr(10)

wordobj.selection.TypeText “MailFile=” & ClientMailFile & Chr(10)

wordobj.selection.TypeText “Location=” & ClientLocationDoc & Chr(10)

wordobj.selection.TypeText “StackedIcons=1” & Chr(10)

wordobj.selection.TypeText “TCPIP=TCP,0,15,0” & Chr(10)

wordobj.selection.TypeText “Ports=TCPIP” & Chr(10)

wordobj.selection.TypeText "KeyFileName = " & Chr(10)

wordobj.selection.TypeText “TemplateSetup=600400” & Chr(10)

wordobj.selection.TypeText “Setup=650200” & Chr(10)

’ Make directory on pc

Mkdir “c:\stagingr6”

’ Save file as notes.ini in text format

wordobj.ActiveDocument.SaveAs “c:\stagingr6\notes.ini”, 2

’ Close word

wordobj.Quit

End Sub

Subject: Create Object Method would not work

Hi,

Thanks for the response but the CreateObject() method used in the code would not work since the Server is deployed on Unix.

Thanks & Regards,

Amit