Send Notes document as PDF attachment

Sub Click(Source As Button)
	'// Declarations
	Dim wApp As Variant 
	Dim ws As NotesUIWorkspace
	Dim s As NotesSession
	Dim uidoc As NotesUIDocument, nuidoc As NotesUIDocument
	Dim path As String, fpath As String, unid As String 
	Dim doc As NotesDocument 
	Dim rt As NotesRichTextITem 
	Dim mdb As NotesDatabase 
	'// Set temp file location
	tpath = "C:\Personal\"
	'// Initialize
	Set s = New NotesSession 
	Set ws = New notesuiworkspace
	Set uidoc = ws.CurrentDocument
	unid = uidoc.Document.UniversalID
	fpath = tpath+unid+".pdf"
	Call uidoc.SelectAll
	Call uidoc.Copy
	'// Open OLE Object
	Set wApp=CreateObject("Word.Application")
	Call wApp.Documents.Add()
	wApp.Visible = False
	wApp.ActiveDocument.SaveAs fpath, 17
	'// Close OLE Object 
	wApp.ActiveDocument.Close wdSaveChanges
	'// Open new mail 
	Set mdb = s.Getdatabase(s.Getenvironmentstring("MailServer", True), s.Getenvironmentstring("MailFile", True), False)
	Set doc = New NotesDocument(mdb) 
	doc.Form = "Memo" 
	Set rt = doc.CreateRichTextItem("Body")
	Call rt.EmbedObject(Embed_Attachment, "", fpath, "test" )
	Call doc.Save(True, False) 
	Call ws.Editdocument(True, doc) 
	Call doc.RemoveItem("SaveOptions")
	'// Remove tmp file 
	Kill fpath 
End Sub
All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.
No comments yetLogin first to comment...