Manuais
PHC GO Funções SDK - Email
 

Email

This class contains functions that allow you to send emails.
 
 

 

Description

Sends an e-mail.
 

Return Function

A logical value that indicates whether the mail was sent.
 

Parameters

 
Name Description Type
from The email account for sending email String
to The email account for email receiver String
subject Email subject String
body Email body String
isBodyHTML A logical value indicating whether the mail message body is in HTML Boolean
cc The email account for email cc receiver String
bcc The email account for email bcc receiver String
attachments Files attached to email message. This parameter is optional and the default value is Nothing. List(Of FileAttachment)
 

Example

 
´This example sends an email to the supervisor when a user creates a customer (business rule "Ao Gravar" implementation) 


    Dim customer as ClVO = DirectCast(itemVO, ClVO)


    ´Checks if it is an operation to create a new customer 


    if customer.Operation = 1 then


    Dim currentUser as UserVO = SDK.User.getCurrentInfo()
 
    Dim route as string = SDK.Route.GetEntityRoute(Of ClVO)(SDK.Route.EntityRouteTypes.View, customer.clstamp) 

    Dim subject as string = "New customer was created" 

    Dim body as string = "<h1>New customer was created by user "+currentUser.username+"</h1>" 

    body = body + "<p>Name: "+customer.nome+"</p>" 

    body = body + "<p>Click <a href=´"+route+"´>here</a> to check the customer record.</p>" 

    SDK.Email.Send("from@phcsoftware.com","supervisor@phcsoftware.com",subject,body,True) 


     end if 
    
 

Example 2

 
´This example sends by email a CSV file with a list of all inactive customers 


    Dim listOfClients as List(Of ClVO) = SDK.Query.getEntityData(of ClVO)(New FilterItem(CL.inactivo, Comparison.Equal, "1")) 

    Dim csvContent As List(Of String) = (From client In listOfClients Select client.nome + ";"+  client.email).ToList ´Creates CSV content 

    SDK.FileUtil.WriteLinesToCsv("InactiveClients.csv",csvContent) 


    Dim AttachmentsList as New List(Of FileAttachment)() 

    AttachmentsList.Add(sdk.FileUtil.getFile("InactiveClients.csv")) 

    SDK.email.send("from@phcsoftware.com", "to@phcsoftware.com", "Subject", "Body" , True, AttachmentsList) 
    

 
 

Description

Sends an e-mail using an e-mail template.
 

Return Function

A logical value that indicates whether the mail was sent.
 

Parameters

 
Name Description Type
from The email account for sending email String
to The email account for email receiver String
cc The email account for email cc receiver String
bcc The email account for email bcc receiver String
emailTemplateStamp The stamp of the email template String
emailTemplateRecordStamp The record stamp String
attachments Files attached to email message. This parameter is optional and the default value is Nothing. List(Of FileAttachment)
 

Example


´This example sends to the customer an email with the account statement 


     Dim recordStamp as string = "6b5-4c9e-b77b-f96932e1dd1" ´The customer stamp 


     Dim templateStamp as string = "z202103121539517820055076" ´The email template stamp (Conta Corrente do Cliente) 


     SDK.Email.Send("from@phcsoftware.com","to@phcsoftware.com","", "", templateStamp, recordStamp) 
    

 
 
 

Description

Gets email template record after processing table and record.
 

Return Function

TemplateEmailVO
 

Parameters

 
Name Description Type
emailTemplateStamp The email template stamp String
recordStamp The record stamp. It must be a record from email template’s entity. String
 

Example


Dim emailTemplateStamp = "z202103121539517820055076" ´Internal template Conta Corrente do Cliente

Dim clientStamp = "6b5-4c9e-b77b-f96932e1dd1" ´Albertino Maciel´s stamp

Dim processedTemplate = SDK.Email.ProcessEmailTemplateBody(emailTemplateStamp, clientStamp)

 
 

Description

Add portal link to e-mail body.
This function only has effect on FT, BO, RE and PO entities. .
 

Return Function

The e-mail body with portal link
 

Parameters

 
Name Description Type
entityname The name of the entity, for example Clients is CL, Invoicing Documents is FT, Suppliers is FL, Purchases is FO String
recstamp The stamp of the document that will be downloaded when the user clicks the link String
emailbody The e-mail body String
 

Example


Dim FtRecord = SDK.Query.GetEntityData(Of FtVO)(New FilterItem(Ft.ftstamp, Comparison.Equal, "´z202002171526455260076073´")).FirstOrDefault() 


Dim emailBody as string = "We have yet to receive payment for invoice number " + FtRecord.uniqueid + ". Please let us know when we can expect to receive payment, and don’t hesitate to reach out if you have any questions or concerns" 


emailBody = SDK.Email.AddPortalLinkToEmailBody("Ft", FtRecord.ftstamp, emailBody) 


SDK.Email.Send("from@phcsoftware.com",FtRecord.ClVO.email,"Overdue invoice " + FtRecord.uniqueid, emailBody, True) 

 
 

Description

Gets and processes an email template structure
 

Return Function

TemplateEmailVO
 

Parameters

 
Name Description Type
emailTemplateStamp The email template stamp String
record Generic itemVO, e.g. ClVO for clients, FtVO for invoices GenericVO
 

Example


´ This example processes an email template for an invoice record and sends it to the customer
Dim emailTemplateStamp As String = "z202103121542588700055267" ´invoice email template
stamp
Dim ftRecord As FtVO = SDK.Query.getEntityByStamp(of FtVO)("z202310271730525960085129")
´Obtains Ft record by stamp
Dim ProcessedTemplate As EmailTemplateVO =
SDK.Email.ProcessEmailTemplateBody(emailTemplateStamp, ftRecord) ´Processes the e-mail body
template
SDK.Email.Send("from@phcsoftware.com", ftRecord.ClVO.email, ProcessedTemplate.assunto,
ProcessedTemplate.conteudo, True, "","")

 

Description

Gets and processes an email template table structure
 

Return Function

EmailTemplateVO
 

Parameters

 
Name Description Type
itemVO An object representing the email template EmailTemplateVO
datasource A list of data to be processed in the table IList
 

Example


Dim emailTemplateStamp = "z202103121542588700055267" ´invoice email template stamp
Dim ftRecord As FtVO = SDK.Query.getEntityByStamp(of FtVO)("z202310271730525960085129")
´Obtains an invoice by stamp
Dim ProcessedTemplate As EmailTemplateVO =
SDK.Email.ProcessEmailTemplateBody(emailTemplateStamp, ftRecord) ´Processes the e-mail body
template
Dim dataSource As New List(Of FiVO)
dataSource = SDK.Query.GetEntityData(Of FiVO)(New FilterItem(Fi.ftstamp, Comparison.Equal,
"´z202310271730525960085129´")) ´Obtains the invoice document lines by stamp
Dim templateTableResult As EmailTemplateVO =
SDK.Email.ProcessEmailTemplateBodyTable(ProcessedTemplate, dataSource) ´Processes the e -mail
body table
SDK.Email.Send("from@phcsoftware.com", ftRecord.ClVO.email, templateTableResult.assunto,
templateTableResult.conteudo,True, "","")