Send email using other people/machine’s email account

Hi @PD2 @vvaidya

I am using Invoke code activity to send SMTP email, but getting an error message listed below:

Error Message: “Invoke Code: Exception has been thrown by the target of an invocation.”

Can you please provide the solution or xlsm file to resolve the issue.

Regardsm,
Sudarshan S N

Hi there,
This is such vague description of problem that likely nobody could help :frowning:
You need to provide much more details about the error and the invoked code.

Cheers

Hi J0ska,

Please find the below code which I used to send email from user 2’s account:

Dim smtpClient As New System.Net.Mail.SmtpClient(in_MailServer)
Dim mailMsg As New System.Net.Mail.MailMessage
Dim sender As New System.Net.Mail.MailAddress(in_Sender)
mailMsg.To.Add(in_MailTo)
mailmsg.Body = in_MailMsgBody
mailMsg.Subject = in_Subject
mailMsg.From = sender
mailMsg.IsBodyHtml = True
smtpClient.Port = Integer.Parse(in_MailPort)
smtpClient.Send(mailMsg)

Regards,
Sudarshan

1 Like

@Suds24,

please check whether you imported outlook namespace

Hi @Suds24,

Like the above user has suggested please verify that the imports tab contains System.Net.Mail

Verify that all the arguments being passed to the invoke code are correct and not null values. Even before the invoke print the values and validate if they are right.

Let me know how that goes!

Regards,
PD

Hi PD2,

After selecting the System.Net.Mail in Imports tab getting the same error message:

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

Can you plz send me the .xaml file if possible.

Regards,
Suds