Dear LimiLabs Team and forum members,
I am trying to download and save specific email attachments for which I am using a regular expression to match a specific pattern. I followed your instructions on how to download all emails which worked well.
However, the goal is to download only pdf-attachments that match a particular pattern. Am I on the wrong track?
Could you please provide a solution and an example on how to filter through attachments. As a starting point for your analysis, please consider the following code (Note I changed the regex a bit, but the pattern I am currently works well, I am more interested in the mechanics on how to properly apply the pattern(s) to filter out the desired pdf-files):
For Each uid As Long In uids
Dim eml() As Byte = imap.GetMessageByUID(uid)
Dim email As IMail = New MailBuilder().CreateFromEml(eml)
For Each pdfattachment In email.Attachments
For Each mime As MimeData In email.Attachments
Static attachmentregex As New Regex("pre-.+?\s+.+?\s+.+?\s+?.+?\s+\d{8}\.pdf")
If attachmentregex.IsMatch(mime.FileName) Then
mime.Save(path2AttachmentFolder + mime.SafeFileName)
End If
Next
Next
Next
Thanks a mil in advance
Sas