A more direct way of creating an Outlook mail item from the Notes client

The best thing about being in software development is learning something new every day. The most humiliating thing in software development is learning that you did something the hard way when there’s a far easier way to do it. That happens most days as well!

So, I was explaining to my manager, Tami Fries, and one of our business users that my method for opening an Outlook message for the end users was a little sloppy, in that it would open two browser tabs (or windows, depending on configuration) before opening the Outlook message. I wondered in the back of my mind if it had to be done that way. They agreed that my helpful message on one of the tabs and titling the tab ‘Close Me’ would probably not generate any confusion. Nonetheless, I wondered.

I remembered vaguely that when I was creating Excel spreadsheets from Notes and silently emailing them in the background from the FAA to Office Depot, that I had to add an extra line of code to make Excel not appear as an active window. So, I looked at the documentation again and found that all I had to do was use the Display method of the MailItem object.

Here’s the code fragment that generates the Outlook message and displays it for further editing. (Note that I used br without the angled brackets in the HTML, since it was reading the HTML and inserting blank lines into the code snippet, but you’ll want those when you drop this into your LotusScript.)

Dim outlook As Variant
Dim message As Variant
Dim itemType As Integer

Set outlook = CreateObject("Outlook.Application")

If ( outlook Is Nothing ) Then
	Call ws.Urlopen(shareViaMailToURL(subject, doc))
	body = "Here is a link to " & subject
	body = "Your approval has been requested for changes made using " & changeOrderNumber (0) & " in " & thisdb.Title
	body = body & "br br"// replace with the angled bracketed HTML for two line breaks
	body = body & "Please review these changes and approve, provide comments, or request more time to review within five business days of this notification. Otherwise, the change will be considered approved as per DAI policy."
	body = body & "br br"// replace with the angled bracketed HTML for two line breaks
	body = body & "The pending change approval form and links to draft documents can be found here: "
	body = body & "br br"// replace with the angled bracketed HTML for two line breaks
	body = body & "Notes:///" & thisdb.ReplicaID & "/0/" & doc.UniversalID

	' 0 is mail item '
	itemType = 0
	Set message = outlook.CreateItem(itemType)
	message.Subject = subject
	message.HTMLBody = body
End If

The shareViaMailToURL is intended to run if the user doesn’t have Outlook, so that it will use the previously supplied code to open the mailto URL using the code in that earlier post.

So incredibly simple in either method.

Categories: Old Notes, Utilities | Tags: , , , | Leave a comment

Post navigation

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: