Hi,
I have an assignment to read mails from Outlook and store them in DB in C# plateform.
When I read the attachment File and store its contents in BYTE[] when I run the query to store contents in Database it is throwing EXCEPTION
"An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Add a name or single space as the alias name.
The name "System.Byte" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted. "
.
What should I do to Store the Contents. I am Reusing the code from online Help.
for (int j = 1; j <= ((Microsoft.Office.Interop.Outlook.MailItem)myInbox.Items[i]).Attachments.Count; j++)
{
string filePath = Path.GetDirectoryName(System.Windows.Forms.Application.StartupPath) + ((Microsoft.Office.Interop.Outlook.MailItem)myInbox.Items[i]).Attachments[j].FileName; // @"G:/prabu"
((Microsoft.Office.Interop.Outlook.MailItem)myInbox.Items[i]).Attachments[j].SaveAsFile(filePath);
FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
int length = (int)fs.Length;
content = new byte[length];
fs.Read(content, 0, length);
fs.Close();
FileInfo f = new FileInfo(filePath);
f.Delete();
}
when Content Type is in Query it is "System.Byte" Hope You Guys have got the problem i m not pretty good with coding so please exuse if couldn't convey in a Better way.
Regards,
Hamza