NSMutableAttributedStringMBS problems

A while ago I started making emails with NSSharingServiceItemsMBS. But I couldn’t get blockquotes to work with NSSharingServiceItemsMBS. So I now made some regex to get the text of blockquoted parts and the level of the quotes. This works fine. But I have 2 problems left.

Here is my html for testing:

test before quote

quote 1

quote 2

quote 1

no quote

When creating NSMutableAttributedStringMBS I can’t get the font and font size to work. And I can’t figure out why the last line is indented when it shouldn’t be.

My result is:

Code for testing:

dim theText as String = "<p>test before quote</p>,<p>quote 1</p>,<p>quote 2</p>,<p>quote 1</p>,<p>no quote</p>"
dim Blocks(-1) as String = theText.Split(",")
dim LevelText as String = "0,1,2,1,0"
dim theLevels(-1) as String = LevelText.Split(",")

Dim documentAttributes As Dictionary
Dim documentOptions As New Dictionary

// define the text encoding
Const NSUTF8StringEncoding = 4
documentOptions.Value(NSAttributedStringMBS.NSCharacterEncodingDocumentOption) = NSUTF8StringEncoding
documentOptions.Value(NSAttributedStringMBS.NSTimeoutDocumentOption) = 30
Dim theFont as NSFontMBS = NSFontMBS.fontWithName("Helvetica", 14.0)
documentOptions.Value(NSAttributedStringMBS.NSFontAttributeName) = theFont

dim FinalString as new NSMutableAttributedStringMBS

for currentBlockquote as Integer = 0 to Blocks.LastIndex
  Dim MutableString As New NSMutableAttributedStringMBS
  call MutableString.initWithHTML(Blocks(currentBlockquote), documentOptions, documentAttributes)
  
  if val(theLevels(currentBlockquote)) > 0 then
    Dim theRange As NSRangeMBS = New NSRangeMBS(0, MutableString.Length - 1)
    Dim MutableStyle As New NSMutableParagraphStyleMBS
    MutableStyle.setHeadIndent(10 * val(theLevels(currentBlockquote)))
    MutableStyle.setFirstLineHeadIndent(10 * val(theLevels(currentBlockquote)))
    MutableString.addAttribute(MutableString.NSParagraphStyleAttributeName, MutableStyle, theRange)
  end if
  
  FinalString.appendAttributedString(MutableString)
next

'make email
Dim items As New NSSharingServiceItemsMBS
items.AddAttributedString(FinalString)
Dim service As New NSSharingServiceMBS("com.apple.share.Mail.compose")
service.subject = "theSubject"
service.setRecipients array("mail@beatrixwillius.de")
service.performWithItems items

@Christian_Schmitz : do you have an idea how to solve the problem?

Sorry, no.