none
Outlook does something with message created out of VB.net RRS feed

  • Question

  • Hello, I really need help understanding this problem.
    I wrote an application which interfaces with Outlook 2010 using Microsoft.Office.Interop

    Basically, out of an TextBox I populate an email which is then sent out of Outlook with the Send() Method.
        Imports Microsoft.Office.Interop
        Dim oMail As Outlook.MailItem

        oOutlook = New Outlook.Application()
        oMAPI = oOutlook.GetNamespace("MAPI")
        oMAPI.Logon(, , True, True)
        oMail = oOutlook.CreateItem(Outlook.OlItemType.olMailItem)
        oMail.Subject = tbMailSubject.Text
        oMail.Body = tbMailBody.Text
        oMail.To = tbMailTo.Text
        For Each strAttachment In lbMailAttachments.Items
            oMail.Attachments.Add(strAttachment.ToString) 'path/name of attachment
        Next
        oMail.BodyFormat = Outlook.OlBodyFormat.olFormatPlain
        oMail.Send()

    Now, so far so good, everything works fine. The mails are sent and are readable, except for the case
    that the mail contains special characters (spanish to be exact).
    Then, the mail, when viewed by the recipient, has an strange header in the body like this:

    Date: Thu, 19 Jul 2012 22:16:58 +0200
    Message-ID: <004601cd65eb$73295160$597bf420$@dinatali.com>
    X-Mailer: Microsoft Outlook 14.0
    Thread-Index: Ac1l62+K1evW+w5YRsmLWjtbdbQflw==
    Content-Language: it

    Buenos dias Maria,
    Agradecemos que nos hayan contactado, aquí estamos de nuevo en la isla
    mágica dispuestos a satisfacer sus exigencias.

    Well, if I copy the message from the SentItems Folder and do paste it into a new mail with the same recipient then the message arrives without additional header data.

    The Outlook options are to Send every outgoing message in PlainText (otherwise it would not work), to Encode the Attachment as UUENCODE (otherwise the attachments are included in the body, unreadable, and the message becomes Mime Multipart) and as International Option Automatically select encoding for outgoing messages.

    Is there something I can pass to the oMail Item in VB which tells Outlook to not create those header lines?
    I did read a lot about Encoding of the mail body but truly did not understand. What is the difference when the mail is created straight in Outlook or via VB.net application

    Every hint is appreciated.
    Luigi

    VS2008 - Outlook2010 - W7


    W764 - VS2008

    Thursday, July 19, 2012 9:05 PM

Answers

  • It sounds like you have a recipient name or a subject that includes a carriage return.

    MS fixed that problem for the Subject header back in Outlook 2002 (?) timeframe, but I bet there is another header with a carriage return.

    If you look at the received message with MFCMAPI or OutlookSpy (click IMessage), what do you see in the PR_TRANSPORT_HEADERS property? What is the last header?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.3 is now available!

    • Marked as answer by ODIC Saturday, July 21, 2012 2:22 PM
    Thursday, July 19, 2012 10:18 PM

All replies

  • It sounds like you have a recipient name or a subject that includes a carriage return.

    MS fixed that problem for the Subject header back in Outlook 2002 (?) timeframe, but I bet there is another header with a carriage return.

    If you look at the received message with MFCMAPI or OutlookSpy (click IMessage), what do you see in the PR_TRANSPORT_HEADERS property? What is the last header?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.3 is now available!

    • Marked as answer by ODIC Saturday, July 21, 2012 2:22 PM
    Thursday, July 19, 2012 10:18 PM
  • Many many thanks.
    That was it.
    At the very end I had a CR in the subject of the mail.
    Now I do replace CR & LF with "" when
    populating the mail fields and everything works as expected.
    Problem solved.

    Thanks again and ciao.

    Luigi

    W764 - VS2008

    Saturday, July 21, 2012 2:21 PM