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

Please use code tags when posting code on Daniweb:

[code]

...code here...

[/code]

You need to post the full code where you are reading in the file and where you are inserting it in the database. How you are communicating with the database server makes a big difference for binary data.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.