Dim Matches As MatchCollection = Regex.Matches(Message.Body, "\[#(?<attachment>.*)#\]")
Dim Match As Match
For Each Match In Matches
' Determine whether the attachment is a URL or a local file.
If Match.Groups("attachment").Value.IndexOf("://") > 0 Then
AttachmentPath = DownloadTempFile(Match.Groups("attachment").Value)
Else
AttachmentPath = System.IO.Path.Combine(BasePath, Match.Groups("attachment").Value)
End If
' Confirm that the file does indeed exist
If System.IO.File.Exists(AttachmentPath) Then Message.Attachments.Add(New Attachment(AttachmentPath))
Next