Skip to Content

Send notification via DI API with attached PDF of new document

Jul 19, 2017 at 03:30 PM


avatar image

Hi everyone!

I already have a breakthrough in a project, but I got stuck in the section of sending internal notifications (SAP B1) and by mail. I have the following functions:

private void EnviarCorreo(string Cotizacion, string Cliente) { try { MailMessage mail = new MailMessage(); mail.From = new MailAddress("no-reply@..", "Cotizaciones SAP"); mail.To.Add(new MailAddress("l.v@.."));

SmtpClient client = new SmtpClient(); client.Port = #puerto; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.Host = ".."; mail.Subject = "Se agregó una cotización por medio del portal"; mail.IsBodyHtml = true; mail.Body = "Se agregó una nueva cotización<br/><br/>Número: <strong>" + Cotizacion + "</strong><br/>Cliente: <strong>" + Cliente + "</strong><br><br>LV"; client.Send(mail); } catch (Exception e) { Console.WriteLine("No se pudo crear el email\n\n" + e.ToString()); } }

private void MandarMensaje(string sKey, string Cliente) { //DATOS DEL ENVIO DE MENSAJE SAPbobsCOM.Message oMessage = null; SAPbobsCOM.MessageDataColumns pMessageDataColumns = null; SAPbobsCOM.MessageDataColumn pMessageDataColumn = null; SAPbobsCOM.MessageDataLines oLines = null; SAPbobsCOM.MessageDataLine oLine = null; SAPbobsCOM.RecipientCollection oRecipientCollection = null; SAPbobsCOM.CompanyService oCmpSrv; SAPbobsCOM.MessagesService oMessageService;

try { oCmpSrv = oCompany.GetCompanyService(); //get msg service oMessageService = (SAPbobsCOM.MessagesService)oCmpSrv.GetBusinessService(SAPbobsCOM.ServiceTypes.MessagesService); oMessage = ((SAPbobsCOM.Message)(oMessageService.GetDataInterface(SAPbobsCOM.MessagesServiceDataInterfaces.msdiMessage)));

//Asunto y texto de la notificación interna de SAP oMessage.Subject = "Se agregó una nueva cotización | " + sKey; oMessage.Text = "Se agregó la cotización número: " + sKey + ", del Cliente: " + Cliente + "\n\nPara ver los detalles oprime la flecha amarrilla debajo..";

oRecipientCollection = oMessage.RecipientCollection; oRecipientCollection.Add(); oRecipientCollection.Item(0).SendInternal = SAPbobsCOM.BoYesNoEnum.tYES; oRecipientCollection.Item(0).UserCode = "user"; pMessageDataColumns = oMessage.MessageDataColumns; pMessageDataColumn = pMessageDataColumns.Add();

//Nombre de columna en el panel inferior de la notificación interna de SAP pMessageDataColumn.ColumnName = "Detalles";

pMessageDataColumn.Link = SAPbobsCOM.BoYesNoEnum.tYES; //get lines oLines = pMessageDataColumn.MessageDataLines; //add new line oLine = oLines.Add();

//Texto de la línea con el enlace al documento oLine.Value = "Enlace a Cotización: " + sKey; //Número de objeto cotización = 23 oLine.Object = "23"; //set the bo code oLine.ObjectKey = sKey; //Enviar mensaje oMessageService.SendMessage(oMessage); } catch (Exception ex) { MsgBox("Error al enviar mensaje " + ex.Message, this.Page, this); } }

So far so good, both functions work just fine.. but with text only, I have not managed to find the way to attach the newly created document in PDF format as SAP allows it natively when wanting to send a notification from the interface.

I hope you can guide me. Thank you in advance for your support and any examples or documents that may be helpful.

Best regards. -Luis

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers