Sep 14, 2017 1:09 PM
7 Posts
topic has been resolvedResolved

Issue With CRLF, Please Help!

  • Category: Application Development
  • Platform: All Platforms
  • Release: 9.0.1
  • Role: Developer
  • Tags:
  • Replies: 1

I am attempting to create a MIME email that is actually a calendar invite, I'm most of the way there I believe though am having troubles with the line feeds.  I am receiving an .ics file in the recipient's mailbox and upon validating it (and viewing it in Notepad++) I am seeing that at the end of every line is LF, the validation tool indicates that there must be CRLF.  So I've attempted all of the following:

& Chr$(13) & Chr$(10)

& Chr(13) & Chr(10)

& Chr(13)

& Chr(10)

& "\n"

 

ALL of the above produce the exact same thing, ONLY the LF at the end of each line!!

 

And for those who may ask, here's the entire routine:

 

Sub

EmailMIME(scheduleDoc As NotesDocument)

 

' Sends the email message as MIME so that the users' mail client can process the content as an invitation

 

Dim s As New NotesSession

Dim db As NotesDatabase

Dim stream As NotesStream

Dim invitation As NotesDocument

Dim MIMEbody As NotesMIMEEntity

Dim MIMEheader As NotesMIMEHeader

Dim SendTo As String ' A comma separated string

Dim CopyTo As String ' A comma separated string

Dim tmpItem As NotesItem

Dim calendarString As String

 

Print "2. Creating invitation as MIME email"

 

SendTo = Join(scheduleDoc.CalEntryInvitees, ",") ' Consider using variant of the EmailRecipents function

CopyTo = ""

 

Set db = s.CurrentDatabase

s.ConvertMIME = False ' Do not convert MIME To rich Text

 

Set stream = s.CreateStream

Set invitation = db.CreateDocument

 

' Create the body entity

Set MIMEbody = invitation.CreateMIMEEntity

 

' Build invitation string here

calendarString = "BEGIN:VCALENDAR" & Chr$(13) & Chr$(10)

calendarString = calendarString & "VERSION:2.0" & Chr$(13) & Chr$(10)

calendarString = calendarString & "PRODID: -//TMIC//Legal Matters Application" & Chr$(13) & Chr$(10)

calendarString = calendarString & "METHOD:REQUEST" & Chr$(13) & Chr$(10)

calendarString = calendarString & "BEGIN:VEVENT" & Chr$(13) & Chr$(10)

calendarString = calendarString & "DTSTART:" & utFormatTheDate(scheduleDoc.StartDate(0)) & "T" & utFormatTheTime(scheduleDoc.StartTime(0)) & Chr$(13) & Chr$(10)

calendarString = calendarString & "DTEND:" & utFormatTheDate(scheduleDoc.EndDate(0)) & "T" & utFormatTheTime(scheduleDoc.EndTime(0)) & Chr$(13) & Chr$(10)

calendarString = calendarString & "DTSTAMP:" & utFormatTheDate(Today) & "T" & utFormatTheTime(Format(Now, "Long Time")) & Chr$(13) & Chr$(10)

calendarString = calendarString & "UID:" & scheduleDoc.UniversalID & Chr$(13) & Chr$(10) 'uid & "\n"

calendarString = calendarString & "ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;RSVP=FALSE;CN=" & Join(scheduleDoc.CalEntryInvitees, ",") &";X-NUM-GUESTS=0:mailto:" & Join(scheduleDoc.CalEntryInvitees, ",") & Chr$(13) & Chr$(10)

calendarString = calendarString & "CLASS:PUBLIC" & Chr$(13) & Chr$(10)

calendarString = calendarString & "CREATED:" & utFormatTheDate(Today) & "T" & utFormatTheTime(Format(Now, "Long Time")) & Chr$(13) & Chr$(10)

calendarString = calendarString & "DESCRIPTION:" & scheduleDoc.Comments(0) & Chr$(13) & Chr$(10)

calendarString = calendarString & "LAST-MODIFIED:" & utFormatTheDate(Today) & "T" & utFormatTheTime(Format(Now, "Long Time")) & Chr$(13) & Chr$(10)

calendarString = calendarString & "LOCATION:" & scheduleDoc.CalEntryLocDefault(0) & Chr$(13) & Chr$(10)

calendarString = calendarString & "SEQUENCE:" & CStr(scheduleDoc.SequenceNum(0)) & Chr$(13) & Chr$(10)

calendarString = calendarString & "STATUS:CONFIRMED" & Chr$(13) & Chr$(10)

calendarString = calendarString & "SUMMARY:" & scheduleDoc.SubjectText(0) & Chr$(13) & Chr$(10)

calendarString = calendarString & "TRANSP:OPAQUE" & Chr$(13) & Chr$(10)

calendarString = calendarString & "END:VEVENT" & Chr$(13) & Chr$(10)

calendarString = calendarString & "END:VCALENDAR" & Chr$(13) & Chr$(10)

 

' Create header

Set MIMEheader = MIMEbody.CreateHeader("Content-Class")

Call MIMEheader.SetHeaderVal("urn:content-classes:calendarmessage")

Set MIMEheader = MIMEbody.CreateHeader("Content-Type")

Call MIMEheader.SetHeaderVal("text/calendar;method=REQUEST;charset=UTF-8;component=vevent")

 

Call stream.WriteText(calendarString)

 

' Ensure the MIME content will be recognized as HTML (Must be after the stream Is written)

Call MIMEbody.SetContentFromText(stream, "text/calendar;method=REQUEST;charset=UTF-8", ENC_NONE)

 

With invitation

.Form = "memo"

 

Set tmpItem = New NotesItem(invitation, "SendTo", Split(SendTo, ","), NAMES)

tmpItem.IsSummary = True

 

If CopyTo = "" Then

.ReplaceItemValue "CopyTo", ""

Else

Set tmpItem = New NotesItem(invitation, "CopyTo", Split(CopyTo, ","), NAMES)

tmpItem.IsSummary = True

End If

 

If scheduleDoc.meetingdocid(0) = "" Then

' New invitation

.ReplaceItemValue "subject", scheduleDoc.SubjectText(0) ' Used by some systems such as Exchange

Else

' Update/Cancellation

.ReplaceItemValue "subject", "Update: " & scheduleDoc.SubjectText(0) ' Used by some systems such as Exchange

End If

End With

 

Call invitation.Send(False)

 

Print "3. Sent invitation"

 

s.ConvertMIME = True ' Restore conversion

 

End

 

Sub

Sep 14, 2017 1:34 PM
7 Posts
Works Now

Well now it's working!  I think something must have been cached.