Skip to main content

Send Email from Service Suite

YouUse canthis article when a Service Suite workflow needs to send email through an approved mail provider or internal SMTP path.

What changed in this article

  • Updated the email usingarticle thearound approved Service Suite email client, using both OAuthworkflows and legacymail-provider controls.
  • Added checks for SMTP/API endpoint, authentication, sender ownership, recipient controls, TLS, rate limits, retry behavior, and audit logging.
  • Added guidance to avoid hard-coded passwords, personal mailboxes, and sensitive test data in email clientscontent.
(such

Validation workflow

  1. Confirm the approved mail provider, sender identity, recipient list, and allowed test data before sending email.
  2. Validate authentication, TLS, request payload, response status, and retry/error behavior in a controlled run.
  3. Review logs and received messages without exposing passwords, tokens, or sensitive customer data.

Review note: This page now treats email sending as gmail).an integration with To,data-transmission From,risk cc, subject, body, bcc parameters and attachments.controls.

OAuth cannot send emails on behalf of a user; they must be sent from a service account that acts on behalf of the application itself. This is similar to the process documented for Azure setup in Configuring Email Clients for Outlook 365 Accounts using Oauth2.0.

Password required

The following method allows you to send email, but does not require a password.

var mailService = createOAuthMailClient("dummy@example.com", "QWERTYpoi123!",
    "QWPg646HDmAVa8dnABtTfdKgd6eZPujvtXXYYKM=", "7899fa0a-a899-481c-bdc2-132eec26f708",
    "d9d0bb61-6874-4c0e-8cae-59ad5bce1d4e");
    
mailService.loginWithOAuth();

var msg = mailService.createMailMessage("Email subject","Email body");

//add recipients
msg.addTo(["user1@appvance.com"]);
msg.addCC(["user2@appvance.ai"]);
msg.addBCC(["user3@appvance.com"]);

//add attachment
msg.addAttachment("prueba.jpeg", readBytes("{ds}/test.jpeg"));

//verify email was sent
var sent = mailService.sendEmail(msg);
assertTrue(sent);

//****validations****
wait(10000);

//refresh folder or switch to another folder
mailService.setFromFolder("INBOX");

//get last unread message 
var lastUnread = mailService.getLastUnreadMessages(1);
assertTrue(lastUnread.length === 1);

//get all emails
var allEmails = mailService.getAllMessages();
assertTrue(allEmails.length === mailService.getMessageCount());


mailService.logout();

Password not required

The following method allows you to send email, but does not require a password. This method uses GraphServiceClient.

public string SendEmail(string fromAddress, string toAddress, string CcAddress, string subject, string message, string tenanatID , string clientID , string clientSecret)
    {
            try
            {
            
            var credentials = new ClientSecretCredential(
                                tenanatID, clientID, clientSecret,
                            new TokenCredentialOptions { AuthorityHost = AzureAuthorityHosts.AzurePublicCloud });
            GraphServiceClient graphServiceClient = new GraphServiceClient(credentials);


            string[] toMail = toAddress.Split(',');
            List<Recipient> toRecipients = new List<Recipient>();
            int i = 0;
            for (i = 0; i < toMail.Count(); i++)
            {
                Recipient toRecipient = new Recipient();
                EmailAddress toEmailAddress = new EmailAddress();

                toEmailAddress.Address = toMail[i];
                toRecipient.EmailAddress = toEmailAddress;
                toRecipients.Add(toRecipient);
            }

            List<Recipient> ccRecipients = new List<Recipient>();
            if (!string.IsNullOrEmpty(CcAddress))
            {
                string[] ccMail = CcAddress.Split(',');
                int j = 0;
                for (j = 0; j < ccMail.Count(); j++)
                {
                    Recipient ccRecipient = new Recipient();
                    EmailAddress ccEmailAddress = new EmailAddress();

                    ccEmailAddress.Address = ccMail[j];
                    ccRecipient.EmailAddress = ccEmailAddress;
                    ccRecipients.Add(ccRecipient);
                }
            }
            var mailMessage = new Message
            {
                Subject = subject,

                Body = new ItemBody
                {
                    ContentType = BodyType.Html,
                    Content = message
                },
                ToRecipients = toRecipients,
                CcRecipients = ccRecipients

            };
            // Send mail as the given user. 
            graphServiceClient
               .Users[fromAddress]
                .SendMail(mailMessage, true)
                .Request()
                .PostAsync().Wait();

            return "Email successfully sent.";

        }
        catch (Exception ex)
        {

            return "Send Email Failed.\\r\\n" + ex.Message;
        }
}

Last updated: JanuaryOctober 16,5, 20242026

If you have any feedback on this topic, please contact us at documentation@appvance.ai.