Downloading the attachment if there is no attachment in the email

Hi,
I am facing an issue, I am reading the email with the subject Customer/customer, sometimes I got a blank email and some time with attachment. where there is an attachment I save in a particular folder and do the further operation. But when there is no attachment with email I just stoped the bot with written log there is no attachment in email and bot will not process further.
But here is when I get a blank email means with no attachment my bot is automatically downloading the attachment(Creating the blank excel file and save in a same folder). Can you please help with this. @Palaniyappan @HareeshMR @Lahiru.Fernando @lakshman

This email has no attachment, Means it’s a proper email but no attachment

And my bot creating this blank excel file.

Even you can see the time also when I receive the email and when bot created the file.

But when I run in debug mode it’s not saving any attachment in the same case but when run in normal mode it’s saving an attachment(created blank excel file) when there is no attachment in an email.

1 Like

@balkishan

Try below one to check whether mail contains any attachment or not.

MailItem.Attachments.Any

1 Like

Use if condition in that
Mailmessage.Attachments.any
if yes then save aatachment in else part put log msg as u need

1 Like

Thanks for the quick response. @lakshman @ImPratham45
you mean here I have to put this condition in yellow marked field
image

Here I am reading and saving

@balkishan

It should be like this:

item.Subject.Contains(“requiredSubject”) AND item.Attachments.Any

1 Like

Okay fine bro, I am implementing this.
I was trying to do like this.
image

Is above method will work. Right me If I am wrong.
Otherwise I will use your condition.

2 Likes

@balkishan

@balkishan

Yes it’s correct. Just try this one in IF condition:

Item.Subject.Contains(“Customer”) or Item.Subject.Contains(“customer”)

1 Like

@balkishan

It should work.
Unless you have something to put in the Else activity, you may choose to put:
item.Subject.ToString.ToUpper.Contains(“CUSTOMER”) AND item.Attachments.Any

Cheers

1 Like

Hi
The condition be like in the first if condition
item.Subject.ToString.ToUpper.Contains(“yourstringincapsletter”)
Then inside condition is perfect

1 Like

Both the condition doesn’t work bro.
image

Still it’s generating the empty excel file.

1 Like

Can I have a view on where we write the excel with a screenshot
@balkishan

Fine are we using any condition filter in get outlook mail activity
Cheers @balkishan

1 Like

This one is also not working bro.

I am wondering how it’s saving the file if there is no attachment in email.

No special condition bro.
image

I didn’t see any property in email which says that if there is no attachment create automatically.

sure bro

1 Like

There is two else which else you want me to use this condition.

1 Like

I have a doubt with excel file been created
Kindly remove that save attachment in the THEN part and check once whether the file is getting created apart from this save attachment activity

Cheers @balkishan

1 Like

Yeah you’re right bro, It’s saving the blank file even I disabled the Save Attachment Activity.

But que is how to find where it’s saving the file.

1 Like

hi @balkishan use bellow condition
item.Attachments.Count>0

great
So kindly check like excel in the universal search in the top right corner of the studio so that we can find where write range activity is used
— or check like InvoiceData.xlsx in the search

We can find that and disable it
And enable back the save attachment and try once
Cheers @balkishan

1 Like