How to send mail using SMTP server through SendGrid mail API?

I am getting this error : “No such host is known” and not able to send mail
But i check the same from : and also able to send .

Can anyone know whats the error or what should i give in “Email” field of logon.

Thanks in advance :slight_smile:

@sup_93 when i used SMTP mail message usually i provide port as:465 and server: “” just try this hope it works. if not plz let me know what has to use.

Hi @sup_93

Send grid recommend to use API key and cannot work with SMTP config given by UIpath (Username need to be email)

Download Send grid nupkg form nupkg source and use below code

"var in_apikey = apiKey.Get(context);

        var in_from = new EmailAddress(from.Get(context), fromName.Get(context));
        var in_to = new EmailAddress(to.Get(context));
        var client = new SendGridClient(in_apikey);
        var msg = MailHelper.CreateSingleEmail(in_from, in_to, subject.Get(context), plainTextContent.Get(context), htmlContent.Get(context));
        Console.WriteLine("Email Request Received");
        var response =  client.SendEmailAsync(msg);
        Console.WriteLine("Sending Email");
        StatusCode.Set(context, response.Result.StatusCode);
        Body.Set(context, response.Result.Body);"
1 Like

Hi @j11
I cannot get your example to work. Can you please help me by explaining a bit more?
I try to copy you code into “Invoke Code”, but it looks lige C#-syntax, which does not seem to be supportet by UiPath Studio (I use 2019.4.4) .
Also I do not understand .Get(context) part. Can you explain it by using arguments?
I want an activity that sends a single mail with HTML-content to a single recipient or a list of recipients, by using SendGrid.