0
votes

The task: To create an email that can result in a calendar entry being created in the recipient's calendar. The same email should work for either a Lotus Notes or Outlook client. The code will be in a LotusScript agent called by the WebQuerySave event on a intranet-based Lotus Notes form (ie. the code runs on the Domino 9 server using the logged-in user's credentials).

It is ok if the user has to click on something in the email to get it to create a calendar entry.

Ideally: I would like to be able to create the MIME content directly without having to mess around with creating ics file attachments, due to restrictive security on the server making it problematic to be creating and removing temp files. Likewise if possible I'd like to avoid 3rd party plug-ins due to the approval process for such things.

I've tried: A few different combinations of writing MIME entries with minor success in the Notes client but no success thus far in the Outlook client. I know what the resulting MIME message should look like (by sending a regular calendar entry created in Lotus Notes to a Thunderbird client and using Ctrl-U to view the source), and I can emulate that, but I've been unable to send that in such a way as it doesn't get scrambled by the mail router.

I tried creating a MIME stream:

' .. Regular setup code here
Set stream = session.Createstream()
session.ConvertMime = False
Set docMemo = db.Createdocument()
docMemo.Form = "Memo"
Set body = docMemo.Createmimeentity
' .. create subject and To fields in the header entity here
Call stream.Writetext(".. the exact text that I want to be in the message as it appears in the recipient inbox in MIME format")
' for example:
' This is a multipart message in MIME format.
' --=_mixed 5DB3BEC8067B2AAFCA2582430012A396_=
' Content-Type: multipart/related; boundary="=_related 5DB3BEC8067B2AAFCA2582430012A396_="
' 
' --=_related 5DB3BEC8067B2AAFCA2582430012A396_=
' Content-Type: multipart/alternative; boundary="=_alternative 5DB3BEC8067B2AAFCA2582430012A396_="
' 
' --=_alternative 5DB3BEC8067B2AAFCA2582430012A396_=
' Content-Type: text/plain; charset=US-ASCII
' Content-Transfer-Encoding: quoted-printable
' 
' =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
' =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
' =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
'                Broadcast: Test outlook 3=20=20=20=20=20=20=20=20=20=20=20=
' =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
' etc...
call body.Setcontentfromtext(stream, "text/HTML;charset=UTF-8", ENC_IDENTITY_7BIT)
Call docMemo.Send(False)
session.Convertmime = True

And I tried putting the MIME-formatted message into a rich text field and converting that to MIME:

' .. Regular setup code here
Set docMemo = db.Createdocument()
docMemo.Form = "Memo"
Set rtiBody = New NotesRichTextItem(docMemo, "Body")
' .. create subject and To fields here
Call rtiBody.AppendText(".. the exact text that I want to be in the message as it appears in the recipient inbox in MIME format")
' same MIME content as code example above
call docMemo.Converttomime(2) ' 2 = CONVERT_RT_TO_HTML_
Call docMemo.Send(False)

I think I must be misunderstanding something fundamental about what the mail router expects and what translations it does.

Another approach is to create a shared calendar link accessible by Outlook as described in this Office support document Create an Add to calendar link in an email message. Sadly this cannot be used as it requires a shared location to store the ics file attachment, which is not suitable in this situation.

I'm pretty much stuck and not sure what to try next.

2

2 Answers

0
votes

If you need full control over the MIME rather than following Torsten's advice, you still don't want to create the MIME headers, separators and content yourself. The NotesMIMEEntity class does that for you, and when you do it that way the router will do the right thing.

You need to use the appropriate methods in that class to set it up. Based on the incomplete code above, you're going to need to create a parent entity, then use CreateChildEntity a child entity of the parent, and use that same method on the child entity to create a child of the child entity. You'll use CreateHeader to set the Content-type of the parent to multipart/related, use the same method set the child's Content-type to multipart/alternative, and again to set the child-of-the-child's Content-type to text/plain. You'll use SetContentFromText to set the message text that you want, and if you really need that to be quoted-printable you'll set that header on the child-of-a-child there, too. I presume that there are at least two other entities corresponding to sections that you're not showing - because you have the two levels of multiparts that obviously should have additional parts to them.

0
votes

Just forget about that "MIME"- stuff completely and create a document with Form "Notice" and fill the needed fields. Domino will create an invitation from that for external recipients automatically. In order to know which fields you have to fill you can use the IBM Calendaring & Scheduling Schema.