Skip to Content
Author's profile photo Pablo Daniel Ilich

How to Send a Mail with Link to the Sales Quote

Hi guys,

I am posting this way to send a Mail to the Approval Party.

In this case i need to sent a Mail to the Appover  with the link to the Sales Quote.

import ABSL;

import AP.FO.Activity.Global as prop;

import AP.Common.GDT as GlobalDataTypes;

import BASIS.Global as globalBasis; //for the pdf

import DocumentServices.Global;

import AP.FO.MOM.Global;

var elEmailRoot : elementsof EmailActivity;

var elEmailParty: elementsof EmailActivity.Party;

var instEmail;

var emailBody;

var emailSubject;

var elEmailTxtColl: elementsof EmailActivity.TextCollection;

var elEmailTxtCollTxt: elementsof EmailActivity.TextCollection.Text;

var elEmailTxtCollTxtCntnt: elementsof EmailActivity.TextCollection.Text.TextContent;

var instEmailTxtColl;

var instEmailTxtCollTxt;

var instEmailTxtCollTxtCntnt;

var instEmailAttFld;    

//Email instance creation

emailSubject = “Notificacion Descuento Manual”;

elEmailRoot.Name.content = emailSubject;

instEmail = EmailActivity.Create(elEmailRoot);     

var aprobador = this.Party.Where(w=>w.RoleCode==”71″).GetFirst();

if(aprobador.AddressSnapshot.DefaultEMail.IsSet())

{

  elEmailParty.PartyKey.PartyID.content =aprobador.AddressSnapshot.DefaultEMail.URI.content;

}

else{

  elEmailParty.PartyKey.PartyID.content = “donotreply@my308221.mail.crm.ondemand.com“;//”8000000102”;

}

instEmail.MessageToParty.Create(elEmailParty);

//Create att folder

instEmailAttFld = instEmail.AttachmentFolder.Create();

//Add attachment1 (html body)

var doctype : GlobalDataTypes:DocumentTypeCode;

var binaryObject : globalBasis:BinaryObject;

var docDesc : GlobalDataTypes:Description;

var docName : GlobalDataTypes:LANGUAGEINDEPENDENT_Name;

var docAltName : GlobalDataTypes:LANGUAGEINDEPENDENT_Name;

var bin : globalBasis:BinaryObject.content;

//Sales Quote Data

var propietario = this.EmployeeResponsibleParty.PartyUUID.content;

var nroOferta = this.ID.RemoveLeadingZeros();

var cliente = this.Party.Where(w=>w.RoleCode==”1001″).GetFirst().Party.CurrentName.PartyFormattedName.content;

var emailFormatted = “<html><head></head><body>”;

//Append to Mail body

//Add a Customer

emailFormatted = emailFormatted+ “<b> “+ cliente + “</b>” +” ha solicitado la aprobaci&oacute;n de descuento para la Oferta de Ventas <b>#”+nroOferta.content.RemoveLeadingZeros()+”</b><BR><BR>”;

emailFormatted = emailFormatted+ “<b>Cliente: </b>”+cliente+” <BR>”;

//GET ALL THE PRODUCTS

//Append to mail body

foreach (var product in this.Item)

{

  var prodDescription = product.Description;

  var descManual = product.DiscountValueManual;

  var valueIVA = product.ValueIVA;

  var impConsumo = product.ConsumerTaxValue;

  var totalValue = product.MotorcycleTotalValuePosition;

  var basePrice = product.BasePrice;

  //Armo el producto

  emailFormatted = emailFormatted + “<b>Producto:</b> ” + prodDescription.content+” <BR>”;

  emailFormatted = emailFormatted + “<b>Precio de Lista:</b> ” + basePrice.content.RoundToString(2)+” <BR>”;

  emailFormatted = emailFormatted + “<b>Descuento Manual:</b> ” + descManual.content.RoundToString(2)+” <BR>”;

  emailFormatted = emailFormatted + “<b>IVA:</b> ” + valueIVA.content.RoundToString(2)+” <BR>”;

  emailFormatted = emailFormatted + “<b>Impuesto al Consumo:</b> ” + impConsumo.content.RoundToString(2)+” <BR>”;

  emailFormatted = emailFormatted + “<b>Valor Total:</b> ” + totalValue.content.RoundToString(2)+” <BR><BR>”;

}

emailFormatted = emailFormatted + “<BR>”;

emailFormatted = emailFormatted + “Por favor dirigase a la oferta”;

//HERE I AM CREATING THE LINK TO THE SALESQUOTE

emailFormatted = emailFormatted + ” <a href=\”https://my308221.crm.ondemand.com/sap/public/ap/ui/repository/SAP_UI/HTML5/client.html?”;

emailFormatted = emailFormatted +  “app.component=/BYD_COD/SalesOnDemand/Quote/COD_Quote_TI.TI.uicomponent&app.inport=Inspect&hideshell=true&Key=ObnKey$”;//%3C?xml version=\”1.0\”%20encoding=\”utf-16\”?%3E”;

emailFormatted = emailFormatted +  “<ObnKey><Source><SourcePath>/BYD_COD/SalesOnDemand/Quote/COD_Quote_OWL.OWL.uicomponent</SourcePath></Source><Path>/Root/CustomerQuote[“;

emailFormatted = emailFormatted + this.UUID.content.ToString() +”]/ID</Path><Data><ID>”+nroOferta.content.RemoveLeadingZeros()+”</ID></Data></ObnKey>\”>”;

emailFormatted = emailFormatted + nroOferta.content.RemoveLeadingZeros() + “</a>”;

//< <

//> >

//Anexo Link para acceder al

docName = “body.html”;

doctype.content = “10001”;

binaryObject.mimeCode = “text/html”;

binaryObject.content = Binary.ParseFromString(emailFormatted + “</body></html>”); //”<html><head>”+this.ActivityReference.GetFirst().CustomerQuote.Name.content +”</head><body><div style=\”font-weight:bold;\”>test</div></body></html>”);

instEmailAttFld.CreateFile(doctype, docName, docAltName, docDesc, binaryObject);

instEmail.Send();

Best Regards,

Pablo

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Hello Pablo,

      Great idea! I have this exact requirement for our customer.

      Could I ask you in which object/event did you insert this custom code?

      Thank you and best regards,

      Alessandra

      Author's profile photo Pablo Daniel Ilich
      Pablo Daniel Ilich
      Blog Post Author

      Hi Alessandra,

      Basically i created an Action called SendMailToAssesor (Example) and i created an WF which activate this action. In my case i had an Indicator Field which when is True then the WF execute this Action.

      Regards. Pablo.

      Author's profile photo Former Member
      Former Member

      Hello Pablo,

      Thank you for the clarification! It is a good starting point for our analysis.

      Best regards,

      Alessandra