Utilizamos cookies para intentar brindarle una mejor experiencia en Freshdesk.
Si desea saber más sobre el tipo de cookies que utilizamos y sobre la forma y motivos por los que las usamos, lea nuestra Política de privacidad. Si no le gustan las cookies o está a dieta, también puede desactivarlas por completo. Solo tenga en cuenta que en Freshdesk nos encantan las cookies (sobre todo las que tienen virutas de chocolate), y que algunos apartados de Freshdesk podrían no funcionar correctamente si las desactiva.
También daremos por hecho que acepta y está de acuerdo con la manera en que usamos las cookies, tal como se describe en nuestra Política de privacidad, a menos que decida desactivarlas por completo a través de su navegador.
En este ejemplo veremos cómo enviar un correo utilizando las tablas de Mails_Outbox y Mails_Outbox_Attachments
Además insertamos un aviso para que se vea en la campana de notificaciones y nos lleve al mail enviado.
Public Shared Function CobroEnviarJustificante(ByVal Entity As EntityObject, ByRef Ret As ProcessHelper, aReportName As String, aEmail As String, aSubject As String, aBody As String, aPath As String, aFileName As String, aCC <span class="fr-marker" data-id="0" data-type="false" style="display: none; line-height: 0;"></span><span class="fr-marker" data-id="0" data-type="true" style="display: none; line-height: 0;"></span>As Object) As Boolean Dim dm As New FLEXYGO.Data.DataManager("DataConnectionString") Dim cdm As New FLEXYGO.Data.DataManager("ConfConnectionString") Dim t As New Translator Dim Agente As String = dm.GetValue(String.Format("Select Nombre + ' ' + Apellidos from Empleados_Datos where IdEmpleado={0}", Entity("IdEmpleado"))) Try Dim Mail As New EntityObject("sysOutboxMail", Ret.ConfToken) Dim Notice As New EntityObject("sysNotice", Ret.ConfToken) Dim ReportDoc As CrystalDecisions.CrystalReports.Engine.ReportDocument Dim PathAttachment As String = Ret.ConfToken.MapPath(aPath & aFileName) If Not IO.Directory.Exists(Ret.ConfToken.MapPath(aPath)) Then IO.Directory.CreateDirectory(Ret.ConfToken.MapPath(aPath)) End If ReportDoc = Entity.GetCrystalReportDocument(aReportName, "", FLEXYGO.Reporting.eReportModes.PDF, Nothing).ReportDoc ReportDoc.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Ret.ConfToken.MapPath(PathAttachment)) Mail("Subject") = aSubject Mail("To") = aEmail Mail("FromEmail") = System.Configuration.ConfigurationManager.GetSection("system.net/mailSettings/smtp").From.ToString() Mail("FromName") = Agente Mail("Body") = aBody Mail("Status") = 1 Mail("ObjectName") = "crm_Actuacion" Mail("ObjectWhere") = "Seguimiento.IdSeguimiento=" & Entity("IdSeguimiento") Mail("ReplyTo") = Ret.ConfToken.UserSecurity.Email Notice("Title") = t.Translate("Envío de justificante de cobro a", eTranslation_Areas.Messages) & " " & aEmail Notice("Message") = aSubject Notice("ReminderTime") = Date.Now Notice("ExpiryTime") = Date.Now.AddDays(7) Notice("AllUsers") = "false" Notice("AllUsersIsSent") = "false" Notice("MethodName") = "app" Notice("TypeId") = "object" Notice("PageTypeId") = "View" Notice("ObjectName") = "sysOutboxMail" Notice("PageName") = "" Notice("TargetId") = "popup" Notice("InsertDate") = Date.Now If Mail.Insert() Then Notice("ObjectWhere") = "(Mails_Outbox.Id='" & Mail("id").ToString & "')" Dim Flag As Boolean = False Dim MailAttachmentError As New Exception Dim MailAttachment As New EntityObject("sysOutboxMailAttachment", Ret.ConfToken) MailAttachment("MailId") = Mail("Id") MailAttachment("Path") = PathAttachment MailAttachment("FileName") = aFileName If Not MailAttachment.Insert() Then Flag = True MailAttachmentError = MailAttachment.LastException Else If Not Notice.Insert() Then Flag = True MailAttachmentError = MailAttachment.LastException Return True Else Dim NoticeUser As New EntityObject("sysNoticeUser", Ret.ConfToken) NoticeUser("NoticeId") = Notice("NoticeId") NoticeUser("UserId") = Ret.ConfToken.UserSecurity.UserId If Not NoticeUser.InsertProcess(NoticeUser.TableName, Settings.ObjectSettings.eUpdateType.Standard, Nothing) Then Flag = True MailAttachmentError = MailAttachment.LastException Return True End If End If End If If Flag Then Ret.Success = False Ret.LastException = MailAttachmentError Return False End If Else Ret.Success = False Ret.LastException = Mail.LastException Return False End If Ret.Success = True Ret.SuccessMessage = t.Translate("Se ha enviado el correo", eTranslation_Areas.Messages) Return True Catch ex As Exception Ret.Success = False Ret.LastException = ex Return False Finally If dm IsNot Nothing Then dm.Close() End If If cdm IsNot Nothing Then cdm.Close() End If End Try End Function0 Votos
0 Comentarios
Iniciar sesión o Registrarse para publicar un comentario