I have a question about email save attachments. I would appreciate it if someone who knows answer.
Is there a way to get the name of the attachment in the email as a variable before downloading it?
* The attachment sent to the e-mail comes with today's date. (exp: Attachment_240701). I want to check if the date matches today's date. If it's true, I want to download the attachment.
Is this possible? or do I have to download it to check?
Thanks in advance.
Page 1 / 1
Hi @ufuksavas,
I believe we cannot do with AA directly; we can only achieve this when we download the attachment and check for filename.
You can use the VB Script to do this. please refer below code which will work with default Outlook application. It will check for unread emails with attachments and gets the attachment name into variable. last it change the email status to read.
Code Snippet is below:
VB Script:
Function FetchEmailAttachName()
' Create an instance of Outlook application Set objOutlook = CreateObject("Outlook.Application")
' Get the MAPI namespace Set objNamespace = objOutlook.GetNamespace("MAPI")
' Get the Inbox folder Set objInbox = objNamespace.GetDefaultFolder(6) ' 6 represents the Inbox folder
' Constant for MailItem type Const olMailItem = 0
' Loop through unread emails in the Inbox For Each objItem In objInbox.Items ' Check if the item is a MailItem If TypeName(objItem) = "MailItem" Then Set objMail = objItem If objMail.UnRead = True Then ' Check if the email has attachments If objMail.Attachments.Count > 0 Then ' Loop through each attachment and display its name For Each objAttachment In objMail.Attachments 'Msgbox("Attachment Name: " & objAttachment.FileName) FetchEmailAttachName = objAttachment.FileName Next Else 'Msgbox("No attachments found in unread email.") FetchEmailAttachName = "No attachments found in unread email" End If
' Mark the email as read (optional) objMail.UnRead = False objMail.Save End If End If Next
' Release the objects Set objAttachment = Nothing Set objMail = Nothing Set objItem = Nothing Set objInbox = Nothing Set objNamespace = Nothing Set objOutlook = Nothing
End Function
Hope it will help. Please let me know.
Thanks,
Hemantha Pindra
Hi everyone,
I have a question about email save attachments. I would appreciate it if someone who knows answer.
Is there a way to get the name of the attachment in the email as a variable before downloading it?
* The attachment sent to the e-mail comes with today's date. (exp: Attachment_240701). I want to check if the date matches today's date. If it's true, I want to download the attachment.
Is this possible? or do I have to download it to check?
Thanks in advance.
As far as I know there is no specific action for your requirement, but as a way around what you can do is, if you are downloading the attachments you will be using a specific subject / sender, in that case you can save the attachment in a specific folder and post that you can use loop for file in a folder and from that you can use the name and delete which are not required.
The way the Email action works it returns a list of emails from the properties of the Connect action. When looping through the list, the command opens the email, downloads ALL attachments to a folder. Within the loop you’d want to process the downloaded files, copying them to a new folder and deleting the files so the folder is empty for the next email. You can grab the name from the Loop for everyfile in a folder with the attributes “name” and “extension”.
The Automation 360 package has “Save all attachments” and “Save attachments”