File names being changed when UiPath attaches to email in SMTP activity

Hi,

I have a component which emails PDFs to a number of recipients and I have noticed that it changes their names slightly, perhaps due to the “&” in them, so instead of “P&L” the attachment is delivered as “P_L_” (underlined, not italic). There is nothing in my component which I think would do this, as I am simply telling UiPath to grab each file in the directory and add it to the email? I have attached a copy in case anyone can easily see the issue?

Thanks
UPSMTP_OpenPopulateNewEmail.xaml (23.6 KB)

1 Like

Actually thats not something that happens in UiPath but in the mail app itself.

See here and example when i manually attached in Outlook:
image

When you download it, it will be there :slight_smile:

Perfect, thanks!

New issue - without changing anything, UiPath is now sending the email as follows:
image

So it is sending the email it should be sending as an attachment to another email where it can’t convert the <br> to html either, and nothing has changed since earlier where it sent them email correctly?

Also, linked to the other topic - this only works in my sandbox, not in the main project despite it being a copy/paste :stuck_out_tongue:

I see you are doing this:

if(mailFPAEmail.Attachments.Count > 0 ,mailFPAEmail, Nothing)

So basically you are sending the same mail as a fwd attachment as well.

I am not receiving the actual email itself though, only the one where it forwards itself, and it worked correctly before?

How is that line sending it again, as this job will only run of there are attachments anyway? Please could you explain, thanks :slight_smile:

So this is what i think i happening.

Here you are sending the email.

  1. To looks good
  2. Subject looks good
  3. Body you are using the same variable that you assign the bodyline to so its giving you that same but not html as you have not used html tags persay only br br
    image
    image

Now that makes up your main email that you are getting:
image

And in the properties you have this:
image
Which again has only your body, and attachments and your subject which you are actually assigning
image

Makes sense?

Yeah, that makes perfect sense, thanks! I have removed the forwarding section in the properties and now the email comes through as intended, and the run actually takes about a minute less as well. I have also changed the “Send SMTP Mail Message” body from mailFPAEmail.Body to just the text I wanted, and now that comes through ok too.

For some reason though - it’s now not attaching the files anymore? Am I missing something really simple here? As you can see, it recognises it should be sending 2 which are in the file, but no longer attaching them? Thanks
image

So without the Forward properties being completed no attachments are sent, but when I have the forward properties filled in, it forwards the actual email it should be sending. So why would this forwarding property affect the actual emails attachments?
Thanks

Here is why.

Attachments you are adding to a mailMessage ‘mailFPAEmail’ using Invoke Method - great
But then in Send SMTP Email, you are not using that mailMessage
What you do is; To, Subject and Body directly. So how does that activity use that mailMessage? there is no link

So what you will have to do is use the mailMessage for to, subject and body and in the fwd part use mailFPAEmail (which you were already doing but missed the logic why it is done that way :slight_smile: )\

Now, this way it will not attach mail again rather it will send you the email as expected.

I am attaching a sample from another thread for you reference Sample_SMTP_Attachement.xaml (11.7 KB)

1 Like

I just tried this, and in forward properties had simply mailFPAEmail, and it went back to forwarding this (which I get why it’s doing that now - as you’re just telling it to forward the mailFPAEmail which I set up.)

However, this is obviously still wrong as I’m not able to send just one email with the reports attached, how do I just send mailFPAEmail with the subject/to/cc/attachments as set, without having to forward it?

Sorry, this is the last thing my bot needs to be complete and it’s wrinkling my brain!

Not sure why its still attaching the mail.
I have used similar approach just that in Outlook and it does not forward.
can you try like this:

Keep only ‘To’ in the activity and the rest as mailMessage.

I’m unable to use Outlook as the VM we are running this off won’t have the required account set up I don’t think, so we re using SMTP for this reason.

I assume it’s forwarding the email as we have created the mailFPAEmail as a variable and are setting that as the “Forward” property - should that not be blank and the attachments configured within the Send SMTP email based off the mailFPAEMail.attachments?

Thats fine. Just that the process is same. So it should work.

Actually from what i have understood is that mail goes 2 ways,

  1. Fill in all the property values, to, subject, body and attachments manually - simple for fixed attachment
  2. Create a mailMessage variable and assign subject, body and attachments(using invoke) and then use that mailMessage as the only property - dynamic attachments

so if you do, mailFPAEMail.attachments how does the activity know that its supposed to send that mailMessage attachment if you dont use it any of the properties?

Did you try with just the To and rest as forward mailMessage?

Hey @ClaytonM, sorry to pull you into this conversation :pleading_face:

But i would love if you would shed some light here on the way things are, and if its been the right way.
Seems to be a weird thing, and im not sure if im missing something. :nerd_face:

I tried, as you suggested, to remove all settings from the Send SMTP message other than the to, and then have mailFPAEmail in the forward, and it sent me a blank email with an attached email which included the reports. Essentially it just didn’t include the body in the main email?

@nadim.warsi no problem :laughing:

I would like to add that sometimes special characters can do weird things. I’ll get back to you if I think of something.

Also, I didn’t get why you are creating a MailMessage with the body, attachments, and everything. Then, I realized you needed multiple Attachments. I’ll get back to you if I think of an alternative to using the Forward Message.

1 Like

One more hit-n-try

Delete the activity and try again with the same setting

Thanks guys!

Which activity do you mean? The Send SMTP?

Yes, if you have not tried already.