將 Crystal Reports 轉換為 HTML 並作為正文發送到我的郵件中 (Crystal Reports into HTML and sending in my mail as body)


問題描述

將 Crystal Reports 轉換為 HTML 並作為正文發送到我的郵件中 (Crystal Reports into HTML and sending in my mail as body)

我在 VB.NET 中使用 Crystal Report。我想使用 Microsoft Outlook 在郵件中將報告作為正文發送。

我的代碼如下,它將 Crystal Report 轉換為 Outlook 正文部分的 html,但它顯示為 html 標籤。

Private Sub FrmViewReport_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Try

        Dim mailbodybutton As New ToolStripButton
        mailbodybutton.Image = ts.Items(10).Image
        ts.Items.Remove(ts.Items(10))
        ts.Items.Insert(10, mailbodybutton)
        AddHandler ts.Items(10).Click, AddressOf CaptureMailBodyEvent

    Catch ex As Exception
        MsgBox(ex.Message)
    End Try
End Sub


Private Sub CaptureMailBodyEvent(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyClass.Click
    Try
        Dim oStream As System.IO.MemoryStream

        oStream = objReport.ExportToStream(CrystalDecisions.Shared.ExportFormatType.HTML40)
        oStream.Position = 0
        Dim sr = New System.IO.StreamReader(oStream)
        Dim html = sr.ReadToEnd()

        Dim app As Microsoft.Office.Interop.Outlook.Application
        Dim appNameSpace As Microsoft.Office.Interop.Outlook.NameSpace
        Dim memo As Microsoft.Office.Interop.Outlook.MailItem

        app = New Microsoft.Office.Interop.Outlook.Application

        appNameSpace = app.GetNamespace("MAPI")

        appNameSpace.Logon(Nothing, Nothing, False, False)

        memo = app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)

        memo.Subject = NVlTrim(m_ReportTitle, "Report")
        memo.Body = html
        memo.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML

        memo.Display()


    Catch ex As Runtime.InteropServices.COMException
        Console.WriteLine(ex.ToString())
    End Try

End Sub

它應該顯示為 Crystal Report 而不是 HTML 標籤中的顯示


參考解法

方法 1:

You should Try

memo.HTMLBody = html

(by Danish SirajSurensiveaya)

參考文件

  1. Crystal Reports into HTML and sending in my mail as body (CC BY‑SA 2.5/3.0/4.0)

#email #outlook #crystal-reports #.net






相關問題

Outlook 2007/2010 中的 Vspace (Vspace in Outlook 2007/2010)

JavaMail 無效的 MSGID (JavaMail invalid MSGID)

將電子郵件地址與地址標籤匹配的正則表達式 (regex that matches email addresses with address tags)

電子郵件地址中帶有 + 字符的 Java 郵件 (Java mail with + character in email address)

PHP mail() 中繼到郵件服務器 (PHP mail() relay to mail server)

在說 smtp.start 時獲取“`initialize': getaddrinfo: nodename nor servname provided, or not known (SocketError)” (Getting "`initialize': getaddrinfo: nodename nor servname provided, or not known (SocketError)" when saying smtp.start)

電子郵件客戶端如何讀取內容類型標頭進行編碼? (How does an email client read the content-type headers for encoding?)

Return-Path 標頭的正確格式 (Correct format of an Return-Path header)

在應用購買中,我如何知道用戶是否已經購買了產品(消耗品)? (in app purchase, how do I know whether a user bought a product (consumable) already?)

將 Crystal Reports 轉換為 HTML 並作為正文發送到我的郵件中 (Crystal Reports into HTML and sending in my mail as body)

通過 smtp 從安裝為 azure 中的 IaaS 的服務器發送電子郵件 (sending emails via smtp from a server installed as IaaS in azure)

如何從 Excel 表格創建電子郵件? (How to create emails from Excel table?)







留言討論