integration between the appplication we are introducing and the customer's
email system. If we are lucky the customer is using Notes as their messaging
system. Unfortunately, this is not always the case and we need to be able to
send from Outlook, or exchange, or some other messaging application. This code
was developed for such a purpose. For this example we are using Outlook 98 on
a Windows system but you could take this and use it (with some modification)
with any mail app.
This really works well for us, you can embelish this with adding attachments,
or sending without presenting to the enduser. We even have one customer where
we are sending the message with a word attachment that is protected for
revision on the fly.
You can really take this base code and go far with it!!
In an agent that is envoked by a form/view action or directly:
Dim ws As New NotesUIWorkspace
Dim strMessageType As String
Set UIdoc = ws.currentDocument
UIdoc.AutoReload = False 'improves performance
Set doc = UIdoc.document
Sub ForegroundOutlook ()
Const BYVALUE = 1 'this is used to attach the actual document not a link
'Get an outlook application object
Set objSession = CreateObject("Outlook.Application")
'Create a new message
Set objMessage= objSession.CreateItem(olMailItem)
'Display the message interface to the user
'Set the subject and message fields
Subject$ = "This is the subject text fo this message"
Message$ = "This is the body text for this message"
QNumber = doc.ordernumber(0)
'The intPosition is used to determine the placement of the attachment in
the message. It is set the space
'immediately following the message.
intPosition = Len(Message$) + 1
Set objRecipient = objMessage.Recipients.Add (sendto)
objMessage.subject = Subject$
objMessage.Body = Message$
'NOTE: there is no send code since that will be done by the user when
'they complete editing / reviewing the message.