Unable to find if any attachment in email

Hi Team,

Very strange problem i am facing , please guide me if i am doing anything wrong anywhere.

Here output of get outlook mail message is emailOutput
For each - System.Net.Mail.MailMesage

I am able get subject but item.Attachment.Any is giving me False value all the time and hence the flow is always going to Else block of code.

Please guide me if any mistake i am doing.

Regards,
Ahtesham

1 Like

Try using the condition as

item.Attachments.Count > 0

@md.ahtesham

@HareeshMR

Very strange , i am not getting even count properly

Not sure what could be issue.

Regards,
Ahtesham

sorry my bad , both count are different … But still attachment count i am getting as 0

Regards,
Ahtesham

EmailOutput.Count gives you number of emails you are reading while item.attachments.count will give you attachment count of that particular email @md.ahtesham.

If you have any attachments in the mail, then it will show the count. Are you sure you have attachments in the mail? Try printing the subject of the mail and check whether that subject mail has the attachment

@HareeshMR

I am getting Subject and that email has attachment (.xlsx) but count is appearing as " 0 "

-Ahtesham

That was strange @md.ahtesham. Can you try restarting the studio and if it doesn’t work, then tryupgrading or downgrading the mail packages of that workflow :slight_smile:

Okay i will try that in my system, But it is very strange…
I tried same in other system which is on 2018.4.3 version and mine on 2019.7.0 and i have received same result.

Regards,
Ahtesham

@HareeshMR / Team
Can someone please test my code it it is working fine for you or it is giving wrong result.
Test2.xaml (12.8 KB)

Regards,
Ahtesham

It is working for me @md.ahtesham

here is the screenshot
image

This is my mail

image

Hi @md.ahtesham,

Could you please try below condition in IF block. It is giving result as you expected :slight_smile:
item.Attachments.Count > 0

image

Hi,

I am still not sure where i am doing wrong.
i am even able to get subject , but not getting attachment value.

Strange part is i have automated a lot of processes this way and all they are running perfectly fine in production.

for Below email
image

-Ahtesham

Thats strange :thinking:

Can you try downgrading the outlook activities and make sure you don’t have any other mail with the same subject but no attachments :slight_smile: @md.ahtesham

I tried downgrading the mail.Activity to 1.2.68**** , but this also didn’t help.

I will look into it later tomorrow. I am also not able to think why attachment value is not populating.

Thanks @HareeshMR

Regards,
Ahtesham

Hi @md.ahtesham,
Please check if you set proper argument type for For Each loop item. In case of Outlook messages it should be the one I’ve marked:
image

Thanks for your reply @Pablito

I am attaching .xaml file . For me it is giving Attachment Count as 0 even though attachment is present in email.

Please verify my .xaml file once if you are getting correct result and revert.
Main.xaml (7.7 KB)

Regards,
Ahtesham

1 Like

Your workflow is working great. Please have a look at my result (I switched from Message Box to Write Line… to many popups :smiley:) :
image
I have other question. Is your outook application open when you are running the process? For Get Outlook Mail Message it needs to be opened. And it needs to be installed version of outlook, not web version.

@Pablito
It is installed and open, and i am able to get email subject but i don’t know i am not able to get the attachment count or Attachment.Any value.

It always saying No Attachment.

I suspect there is some issue with community edition.
Can you please try on community version, coz i tried same code on lots of system and fortunately all are community version and over all the system it gave me same result.

I am just curious to know why my code is not working properly in my system and it is working perfectly fine in your system…

Can you share your .xaml file so that i can run and verify…

Regards,
Ahtesham

1 Like

I am using Community Edition (19.7). Your workflow is working great for me. Maybe something is wrong with your outlook.

Did you find a solution @md.ahtesham ?