How to send a mail without using inbuilt activities?

@Manish540 What is the code?..

1 Like

kindly have a view on this thread

we can use this in INVOkE CODE activity
Cheers @Manish540

Please check this link @Manish540

Its Throwing the exception…


Source: Invoke code

Message: Exception has been thrown by the target of an invocation.

Exception Type: System.Reflection.TargetInvocationException

RemoteException wrapping System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> RemoteException wrapping System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. k3sm18409137pfg.23 - gsmtp
at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response)
at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte command, MailAddress from, Boolean allowUnicode)
at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, Boolean allowUnicode, SmtpFailedRecipientException& exception)
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at UiPathCodeRunner_5adf547f43b848f0b96124091bcef175.Run()
— End of inner exception stack trace —
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object parameters, Object arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object providedArgs, ParameterModifier modifiers, CultureInfo culture, String namedParams)
at UiPath.Activities.System.Utilities.InvokeCode.CompilerRunner.Run(Object args)
at UiPath.Activities.System.Utilities.InvokeCode.NetCodeInvoker.Run(String userCode, List1 inArgs, IEnumerable1 imps, Object args)
at UiPath.Core.Activities.InvokeCode.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

Please post the smtp you are using @Manish540

Another option could be using Powershell for sending email

Dim smtp As New SmtpClient(“”)

This is working code for me now @Manish540

      Dim mail As New MailMessage()
    mail.To.Add("Mail id")
    mail.From = New MailAddress("Mail id")
    mail.Subject = "Confirmation of Registration on Job Junction."
    Dim Body As String = "Hi, this mail is to test sending mail using Gmail in ASP.NET"
    mail.Body = Body
    mail.IsBodyHtml = True
    Dim smtp As New SmtpClient("", 587)

    smtp.UseDefaultCredentials = False
    smtp.EnableSsl = True
    smtp.Credentials = New System.Net.NetworkCredential("Mail id which you gave access to less secure apps", "password of that mail")
1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.