I need to send email to user with voting option yes|No in UiPath. I am invoking vbNet code and want the email to send from specific email id.
Issue is since the bot runs on multiple machines ,emails are getting sent from different email id.
How can I specifiy the sender email id in vbcode.
Pass the sender email address as an argument to the Invoke Code Activity and use it with your VB Code. If you need Credentials then use Orchestrator Assets for all different senders, then use Get Credentials and pass it to the VB Code via arguments of the Invoke Code Activity.
Hi @Rilna_Rilna
Try the method outlined below. It will help you achieve this use case.
Imports System.Net.Mail
’ Replace with the sender’s email address
Dim sender As New MailAddress(“sender@gmail.com”)
’ Replace with the recipient’s email address
Dim recipient As New MailAddress(“recipient@gmail.com”)
’ Replace with the sender’s email password
Dim password As String = “password”
’ Replace with the SMTP server address
Dim smtpServer As String = “smtp.gmail.com”
Dim port As Integer = 587
Dim subject As String = “Email with voting options”
’ Replace with the voting options
Dim options As String = “Option 1, Option 2, Option 3”
’ Create the email message
Dim message As New MailMessage(sender, recipient)
message.Subject = subject
message.Body = options
’ Set up the SMTP client
Dim client As New SmtpClient(smtpServer, port)
client.EnableSsl = True
client.Credentials = New NetworkCredential(sender.Address, password)
Hi @Rilna_Rilna
Try this code for Exchange server mail
Use Invoke Code actions to actieve this.
Imports Microsoft.Exchange.WebServices.Data
Replace with the sender’s email address
Dim sender As New EmailAddress(“sender@domain.com”)
Replace with the recipient’s email address
Dim recipient As New EmailAddress(“recipient@domain.com”) Replace with the sender’s email password
Dim password As String = “password”
Replace with the voting options
Dim options As String = “Option 1, Option 2, Option 3”
Set up the Exchange service
Dim service As New ExchangeService(ExchangeVersion.Exchange2013_SP1)
service.Credentials = New WebCredentials(sender.Address, password)
service.Url = New Uri(url)
Create the email message
Dim message As New EmailMessage(service)
message.ToRecipients.Add(recipient)
message.Subject = “Email with voting options”
message.Body = options
Set the voting options
Dim votingOptions As New StringList()
votingOptions.AddRange(options.Split(“,”))
message.VotingOptions = votingOptions
message.Send()
Thanks alot.
But there is exchange scope activity in UiPath where in we can establish connection to exchange server and then pass that object.( Activity name: Exchange scope)
Can we pass exchange server object from that scope to vbNet?