Email multi recipients and Carbon Copy (CC)

edited February 2015 in FastReport .NET
Hello,
i was trying to send a report programatically to multi email recipients and i dont know why this isn't working...
I tried to separate the email addresses with , or ; but it doesnt work... it don't show any error but it don't send the email...

I tried also use the Carbon Copy option but it show me this error : "Value of type 'String' cannot be converted to '1-dimensional array of String'."

I have another error... i'm using a background image as watermark... when i send the email... the image is not being send... it send the email but without the background image...

Could someone please help me... any idea how to solve this errors?!

This is the code i'm using :
' Prepare Report
        Dim ListReportC = New FastReport.Report
        Dim Factura As String = My.Settings.Reports.ToString & "\Factura_A.frx"
        Dim strSQL As String = "SELECT * FROM VW_CABEC_DOCS  WHERE Codigo LIKE ('" & CodDocumento & "')"
        Dim strSQL2 As String = "SELECT * FROM VIEW_LINHAS_DOCS WHERE Codigo = (SELECT Codigo_Auto FROM VW_CABEC_DOCS WHERE Codigo LIKE ('" & CodDocumento & "')) ORDER BY LINHA"
        Dim digHash As String = Get_Digitos_Hash(CodDocumento)
        Dim strSQL3 As String = "SELECT * FROM IMAGENS_LINHA WHERE ID_LINHA IN (SELECT CODIGO_AUTO FROM DOCUMENTO_LN WHERE CODIGO = (SELECT CODIGO_AUTO FROM DOCUMENTO_CB WHERE CODIGO = '" & CodDocumento & "'))"
        Try
            ListReportC.Load(Factura)
            ListReportC.Dictionary.Connections(0).ConnectionString = My.Settings.InovaConnectionString
        Catch
            DevComponents.DotNetBar.MessageBoxEx.Show("Report file not found!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            Exit Sub
        End Try
        Dim TD As FastReport.Data.TableDataSource = ListReportC.GetDataSource("DOCUMENTO_CB")
        TD.SelectCommand = strSQL
        Dim LD As FastReport.Data.TableDataSource = ListReportC.GetDataSource("DOCUMENTO_LN")
        LD.SelectCommand = strSQL2
        Dim s2Via As FastReport.TextObject = ListReportC.FindObject("s2Via")
        s2Via.Text = " "
        Dim W As New FastReport.Watermark
        W.Enabled = True
        W.Text = " "
        W.TextRotation = FastReport.WatermarkTextRotation.ForwardDiagonal
        Select Case Verifica_Empresa()
            Case "AAAAA, Lda"
                W.Image = My.Resources.PapelAFC
                W.ImageSize = FastReport.WatermarkImageSize.Stretch
            Case "BBBBB, Lda"
                W.Image = My.Resources.papelparabola
                W.ImageSize = FastReport.WatermarkImageSize.Stretch
        End Select
        CType(ListReportC.Pages.Item(0), FastReport.ReportPage).Watermark = W
        Dim mmAnulado As FastReport.TextObject = ListReportC.FindObject("mmAnulado")
        mmAnulado.Text = " "
        Dim mmNCert As FastReport.TextObject = ListReportC.FindObject("mmNCert")
        mmNCert.Text = digHash & "-Processado por Programa Certificado n.?? 666/AT"

        ' Create Export File
        Dim PDFExport As FastReport.Export.Pdf.PDFExport = New FastReport.Export.Pdf.PDFExport
        PDFExport.Background = True
        PDFExport.EmbeddingFonts = True
        PDFExport.Compressed = True
        PDFExport.PrintOptimized = True

        ListReportC.prepare()
        ListReportC.Export(PDFExport, "Factura" & ".pdf")

        ' Account Properties
        Dim EMailExport As FastReport.Export.Email.EmailExport = New FastReport.Export.Email.EmailExport
        EMailExport.Account.Host = Get_Notify_SMTP()          ' SMTP Host
        EMailExport.Account.Address = Get_Notify_FROMEMAIL()  ' From EMail Address
        EMailExport.Account.UserName = Get_Notify_USERNAME()  ' SMTP ID
        EMailExport.Account.Password = Get_Notify_USERPASS()  ' SMTP Password
        EMailExport.Account.Port = 25
        EMailExport.Account.EnableSSL = False

        ' EMail Properties
        EMailExport.Address = Get_Cliente_EMAILNOTIFICAR(CodDocumento)
        EMailExport.CC = "xxxxx.xxxxx@gmail.com"

        Select Case Verifica_Empresa()
            Case "AFC Pereira, Lda"
                EMailExport.Subject = "Notifica?§??o de Transferencia SEPA"
            Case "Par??bola In?©dita"
                EMailExport.Subject = "Notifica?§??o de Transferencia SEPA"
        End Select

        EMailExport.MessageBody = "  " & Chr(10) & Chr(13) & "No pr??ximo dia " & DataVencimento.Substring(0, 10) & " ir?? ser descontado da sua conta o valor de " & Math.Round(Val(Valor.Replace(",", ".")), 2, MidpointRounding.AwayFromZero).ToString & "??????¬ referente ao documento " & CodDocumento & Chr(10) & Chr(13) & "Consultar relat??rio em anexo para mais informa?§?µes." & Chr(10) & Chr(13) & Chr(10) & Chr(13) & "Email enviado automaticamente pelo software Inova Industry"

        ' Send Mail
        EMailExport.Export = PDFExport
        EMailExport.SendEmail(ListReportC)

Comments

  • edited 7:00PM
    Hello,
    i was trying to send a report programatically to multi email recipients and i dont know why this isn't working...
    I tried to separate the email addresses with , or ; but it doesnt work... it don't show any error but it don't send the email...

    I tried also use the Carbon Copy option but it show me this error : "Value of type 'String' cannot be converted to '1-dimensional array of String'."

    I have another error... i'm using a background image as watermark... when i send the email... the image is not being send... it send the email but without the background image...

    Could someone please help me... any idea how to solve this errors?!

    This is the code i'm using :
    ' Prepare Report
            Dim ListReportC = New FastReport.Report
            Dim Factura As String = My.Settings.Reports.ToString & "\Factura_A.frx"
            Dim strSQL As String = "SELECT * FROM VW_CABEC_DOCS  WHERE Codigo LIKE ('" & CodDocumento & "')"
            Dim strSQL2 As String = "SELECT * FROM VIEW_LINHAS_DOCS WHERE Codigo = (SELECT Codigo_Auto FROM VW_CABEC_DOCS WHERE Codigo LIKE ('" & CodDocumento & "')) ORDER BY LINHA"
            Dim digHash As String = Get_Digitos_Hash(CodDocumento)
            Dim strSQL3 As String = "SELECT * FROM IMAGENS_LINHA WHERE ID_LINHA IN (SELECT CODIGO_AUTO FROM DOCUMENTO_LN WHERE CODIGO = (SELECT CODIGO_AUTO FROM DOCUMENTO_CB WHERE CODIGO = '" & CodDocumento & "'))"
            Try
                ListReportC.Load(Factura)
                ListReportC.Dictionary.Connections(0).ConnectionString = My.Settings.InovaConnectionString
            Catch
                DevComponents.DotNetBar.MessageBoxEx.Show("Report file not found!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
                Exit Sub
            End Try
            Dim TD As FastReport.Data.TableDataSource = ListReportC.GetDataSource("DOCUMENTO_CB")
            TD.SelectCommand = strSQL
            Dim LD As FastReport.Data.TableDataSource = ListReportC.GetDataSource("DOCUMENTO_LN")
            LD.SelectCommand = strSQL2
            Dim s2Via As FastReport.TextObject = ListReportC.FindObject("s2Via")
            s2Via.Text = " "
            Dim W As New FastReport.Watermark
            W.Enabled = True
            W.Text = " "
            W.TextRotation = FastReport.WatermarkTextRotation.ForwardDiagonal
            Select Case Verifica_Empresa()
                Case "AAAAA, Lda"
                    W.Image = My.Resources.PapelAFC
                    W.ImageSize = FastReport.WatermarkImageSize.Stretch
                Case "BBBBB, Lda"
                    W.Image = My.Resources.papelparabola
                    W.ImageSize = FastReport.WatermarkImageSize.Stretch
            End Select
            CType(ListReportC.Pages.Item(0), FastReport.ReportPage).Watermark = W
            Dim mmAnulado As FastReport.TextObject = ListReportC.FindObject("mmAnulado")
            mmAnulado.Text = " "
            Dim mmNCert As FastReport.TextObject = ListReportC.FindObject("mmNCert")
            mmNCert.Text = digHash & "-Processado por Programa Certificado n.?? 666/AT"
    
            ' Create Export File
            Dim PDFExport As FastReport.Export.Pdf.PDFExport = New FastReport.Export.Pdf.PDFExport
            PDFExport.Background = True
            PDFExport.EmbeddingFonts = True
            PDFExport.Compressed = True
            PDFExport.PrintOptimized = True
    
            ListReportC.prepare()
            ListReportC.Export(PDFExport, "Factura" & ".pdf")
    
            ' Account Properties
            Dim EMailExport As FastReport.Export.Email.EmailExport = New FastReport.Export.Email.EmailExport
            EMailExport.Account.Host = Get_Notify_SMTP()          ' SMTP Host
            EMailExport.Account.Address = Get_Notify_FROMEMAIL()  ' From EMail Address
            EMailExport.Account.UserName = Get_Notify_USERNAME()  ' SMTP ID
            EMailExport.Account.Password = Get_Notify_USERPASS()  ' SMTP Password
            EMailExport.Account.Port = 25
            EMailExport.Account.EnableSSL = False
    
            ' EMail Properties
            EMailExport.Address = Get_Cliente_EMAILNOTIFICAR(CodDocumento)
            EMailExport.CC = "xxxxx.xxxxx@gmail.com"
    
            Select Case Verifica_Empresa()
                Case "AFC Pereira, Lda"
                    EMailExport.Subject = "Notifica?§??o de Transferencia SEPA"
                Case "Par??bola In?©dita"
                    EMailExport.Subject = "Notifica?§??o de Transferencia SEPA"
            End Select
    
            EMailExport.MessageBody = "  " & Chr(10) & Chr(13) & "No pr??ximo dia " & DataVencimento.Substring(0, 10) & " ir?? ser descontado da sua conta o valor de " & Math.Round(Val(Valor.Replace(",", ".")), 2, MidpointRounding.AwayFromZero).ToString & "??????¬ referente ao documento " & CodDocumento & Chr(10) & Chr(13) & "Consultar relat??rio em anexo para mais informa?§?µes." & Chr(10) & Chr(13) & Chr(10) & Chr(13) & "Email enviado automaticamente pelo software Inova Industry"
    
            ' Send Mail
            EMailExport.Export = PDFExport
            EMailExport.SendEmail(ListReportC)
    



    use array type data for cc

    Dim sAddr() as string = {"addd1", "add2",....""}

    EMailExport.CC = sAddr

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.