Imports System.IO
Imports DevExpress.XtraRichEdit

Public Class ucEnviarCorreo
    Inherits ucBase

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        RegisterCustomMessage(cbpEnviar)

    End Sub

    Protected Sub cbpEnviar_Callback(sender As Object, e As DevExpress.Web.CallbackEventArgsBase) Handles cbpEnviar.Callback
        Dim msg As New MSG("correo")
        Dim arregloUsuarios As New ArrayList
        Dim text As String = ""


        If String.IsNullOrEmpty(txtCorreo.Text) Then

            Dim ListUsuarios As EntityList(Of Usuarios) = UsuariosBusinessObject.GetUsuariosByInstitucion(rblInstituciones.Value)
            For Each usuario As Usuarios In ListUsuarios
                arregloUsuarios.Add(usuario.email)
            Next

        Else
            arregloUsuarios.Add(txtCorreo.Text)
        End If



        Dim ms As New MemoryStream()
        ASPxRichEdit1.SaveCopy(ms, DocumentFormat.Html)
        ms.Seek(0, SeekOrigin.Begin)
        text = New StreamReader(ms).ReadToEnd


        msg = SistemasBusinessObject.EnviarCorreo("NOTIFICACIÓN de Empleos Públicos", text, arregloUsuarios)
        CustomMessage(msg, "Estado de Correo", cbpEnviar)
    End Sub
End Class