I know it is talking to the email because it obtains the subject (please see the message box text with the subject “test 123”) but it just doesn’t return the attachment count.
If you use my code in the initial post, and create a folder test under your inbox, with an email with an attachment, what does your script say? Is this a bug? or is it only happening to me?
I have tested this on another 2 computers, with different email accounts, and all computers show 0 as the attachment count when the email has an attachment…
I am trying to write a script that will process emails with attachments, but it needs to first verify there is an attachment (if there isn’t put the email in cannot process folder due to missing attachment) but I have no way to check if there is an attachment. Any suggestions?
I’m not sure and have not tested .Attachments.Count on my end, however, you could try using “Save Attachments” and use the Output property to store them to a list. Then you can just do list.Count.ToString
If that doesn’t work, then I have no idea what you can try other than that.
The plot thickens.
I can get the message subject,
but I cannot get .attachments or .body
When I run Save attachments, it doesn’t save any attachments, and when I tried your suggestion it tells me the count is 0 in the outputted list.
I am going to now try on another computer with a different email account type (POP3) to see if it is perhaps a security issue with my work computer…
Another update for anyone else who encounters the same issue:
I couldn’t solve this issue after several hours trying,
So I used the workaround of using the Get Exchange Mail Message instead of Get outlook mail message.
(I prefer Get outlook as it is instant, Get Exchange takes about 60 seconds on my computer, likely because my exchange server is on the other side of the world…)
To close this off, my issue turned out to be a security/group policy that my company uses. I don’t know what the policy is, but I found that using a computer with security policies turned off worked…