troubleshooting Question

Lotus Notes Automation using Visual Basic

Avatar of waverazor
waverazor asked on
Lotus IBMVisual Basic.NET
6 Comments1 Solution2810 ViewsLast Modified:
Using Visual Basic 2008 and Lotus Notes 8.5.

I use this code to automate the Lotus Notes UI to create an HTML format email with attachment.
sess = CreateObject("Notes.NotesSession")
ws = CreateObject("Notes.NotesUiWorkspace")
db = sess.GetDatabase("", "", False)

If Not db.IsOpen Then db.OpenMail()
doc = db.CreateDocument()
Call doc.ReplaceItemValue("Form", "Memo")

' add the body as a mime html part
convertMime = sess.convertMime
sess.convertMime = False
stream = sess.CreateStream()

stream.WriteText(strBody)
mimeBody = doc.GetMIMEEntity("Body")

If mimeBody Is Nothing Then
     mimeBody = doc.CreateMIMEEntity("Body")
End If

mimeHtml = mimeBody.CreateChildEntity()
Call mimeHtml.SetContentFromText(stream, "text/html; charset=""iso-8859-1""", ENC_QUOTED_PRINTABLE)
Call stream.Close()

'handle the attachment
If Attachment.Length > 0 Then
                mimeFile = mimeBody.CreateChildEntity()
                mimeHeader = mimeFile.CreateHeader("Content-Transfer-Encoding")
                Call mimeHeader.SetHeaderVal("binary")
                mimeHeader = mimeFile.CreateHeader("Content-Disposition")
                Call mimeHeader.SetHeaderVal("attachment; filename=" & "Order Acknowledgement.pdf")
                Call stream.Open(Attachment, "binary")
                Call mimeFile.SetContentFromBytes(stream, "text/plain", ENC_NONE)
                Call mimeFile.EncodeContent(ENC_IDENTITY_8BIT)
                Call stream.Close()
End If

When I continue the code with this:
            Call doc.Save(True, False)
            uidoc = ws.EditDocument(True, doc)
            Call uidoc.FieldSetText("EnterSendTo", [To])
            Call uidoc.FieldSetText("EnterCopyTo", [CC])
            Call uidoc.FieldSetText("Subject", Subject)

            ' bring the window to the front
            Call AppActivate(uidoc.WindowTitle)
the email is created with the attachment, but the signature block is missing.  I don't beileve the default lotus notes template is being used.

When I substitute the second block of code with this:
           'copy generated HTML to clipboard
            Call doc.Save(True, False)
            uidoc = ws.EditDocument(True, doc)

            Call doc.Remove(True)
            Call uidoc.GotoField("Body")
            Call uidoc.SelectAll()
            Call uidoc.Copy()
            uidoc.Document.SaveOptions = "0"
            uidoc.Document.MailOptions = "0"
            Call uidoc.Close()

            ' compose a new memo and paste the body
            uidoc = ws.ComposeDocument(db.Server, db.filePath, "Memo")
            Call uidoc.GotoField("Body")
            Call uidoc.Paste()

            Call uidoc.FieldSetText("EnterSendTo", [To])
            Call uidoc.FieldSetText("EnterCopyTo", [CC])
            Call uidoc.FieldSetText("Subject", Subject)
then the signature block is there, but the attachment is not copied (missing) from the email.  It seems that the default Lotus Notes template is being used.

I need help with the code so that a HTML format email with attachment is created that uses the default template and has the signature block inserted.  I think the "CreateDocument" and "ComposeDocument" commands use two different templates.

Thanks.


ASKER CERTIFIED SOLUTION
Sjef Bosman
Groupware Consultant

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros