Hello all,
I have a situation where I download a lot of emails in the input folder.
Once downloaded, I am trying to save attachment for each downloaded email.
Does anyone have idea how could I achieve that?
Thank you in advance.
Hello all,
I have a situation where I download a lot of emails in the input folder.
Once downloaded, I am trying to save attachment for each downloaded email.
Does anyone have idea how could I achieve that?
Thank you in advance.
Hi @bp777,
Follow these steps:
Assign
activity to get all email files from the input folder.
emailFiles = Directory.GetFiles("C:\path\to\your\input\folder", "*.eml")
emailFiles
is a variable of type String[]
.For Each
activity.TypeArgument
to String
.Values
field, set it to emailFiles
.Invoke Code
activity to load and parse the email using the MailMessage
class.Dim mail As New System.Net.Mail.MailMessage
Dim client As New System.Net.Mail.SmtpClient
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.SpecifiedPickupDirectory
client.PickupDirectoryLocation = Path.GetDirectoryName(emailFile)
client.Send(mail)
mail = client.SendMailAsync(emailFile).Result
* `emailFile` is the current file in the loop.
If
activity to check if the email has attachments: mail.Attachments.Any
.Save Attachments
activity inside the Then
block of the If
activity.MailMessage
: Set to mail
.FolderPath
: The folder path where you want to save the attachments, e.g., Path.Combine(Environment.CurrentDirectory, "Attachments")
.LLM helped me to write this answer but it’s cross checked by me.
Thanks,
Ashok
Hello,
I get error "error BC30451: ‘emailFile’ is not declared. It may be inaccessible due to its protection level.
You missed to pass the arguments to Invoke code.
Click on Edit Argument and pass like this.
emailFile
is the current file in the loop
Thanks,
Ashok
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.