0

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

Edited by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by sknake
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.