This question is generally out of scope of Mail.dll help forum.
Use IMail.Attachments collection to retrieve attachments' data and file names:
IMail email = ...;
foreach(MimeData att in email.Attachments)
{
string fileName = att.SafeFileName;
byte[] data = att.Data;
// your logic goes here.
}
We can't help you with SQL logic.