how to add header email with Send Email from Outlook (in VB) RRS feed

  • Question

  • how to add header email with Send Email from Outlook (in VB)

    Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
            Dim sSubject As String
            Dim sBody As String
            Dim sTo As String
            Dim sCC As String
            Dim sFilename As String
            Dim sDisplayname As String

            Dim AppID As String
            AppID = LabelAppeal.Text

            Dim oApp As Microsoft.Office.Interop.Outlook.Application
            oApp = New Microsoft.Office.Interop.Outlook.Application

            Dim oMsg As Microsoft.Office.Interop.Outlook.MailItem
            oMsg = oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)

            oMsg.Subject = sSubject("to DIGITAL")
            oMsg.Body = sBody("Dear Sir/Madam, Data Selection file for appealID:" & AppID & "is ready.")

            oMsg.To = sTo("")
            oMsg.CC = sCC

            Dim strS As String = sFilename
            Dim strN As String = sDisplayname
            If sFilename <> "" Then
                Dim sBodyLen As Integer = Int(sBody.Length)
                Dim oAttachs As Microsoft.Office.Interop.Outlook.Attachments = oMsg.Attachments
                Dim oAttach As Microsoft.Office.Interop.Outlook.Attachment

                oAttach = oAttachs.Add(strS, , sBodyLen, strN)

            End If

            MessageBox.Show("Email Send", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)

        End Sub

    how to add header email with this code

    Wednesday, June 13, 2018 7:12 AM

All replies

  • You need to set a string property in the PS_INTERNET_HEADERS space:

    oMsg.PropertyAccessor.SetProperty("{00020386-0000-0000-C000-000000000046}/X-MyCustomHeader", "Some Value")

    Dmitry Streblechenko (MVP)
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Wednesday, June 13, 2018 4:36 PM
  • Hello nafise rezvani,

    What's the current state of the thread? Does Dmitry's suggestion work for you?

    If it does,  I would suggest you mark the reply to close the thread.

    If not, please feel free to let us know the current issue.

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Wednesday, June 20, 2018 9:26 AM