W
W Akthar
I have a problem trying to iterate through the Attachment
Collection.
Even when the count of Attachments is greater than 0 I
still get an error message as follows.
Error: Index (zero based) must be greater than or equal
to zero and less than the size of the argument list.
I have included the code below.
int i = 1;
foreach (Outlook.Attachment att in oMail.Attachments)
{
SqlCommand cmAttachmentCommand = new SqlCommand
("SP_Add_Outlook_Email_Attachments", sqlConn);
cmAttachmentCommand.CommandType =
CommandType.StoredProcedure;
// Add Parameters to SPROC
cmAttachmentCommand.Parameters.Add(new
SqlParameter("@MailAttachmentID", attachmentID));
cmAttachmentCommand.Parameters.Add(new
SqlParameter("@MailAttachmentNumber", i));
cmAttachmentCommand.Parameters.Add(new
SqlParameter("@MailAttachmentType", 1));
// ## ERROR OCCURS HERE !!!!!
cmAttachmentCommand.Parameters.Add(new
SqlParameter("@BlobField", att));
// Open the connection and execute the Command
cmAttachmentCommand.ExecuteNonQuery();
i++;
}
Collection.
Even when the count of Attachments is greater than 0 I
still get an error message as follows.
Error: Index (zero based) must be greater than or equal
to zero and less than the size of the argument list.
I have included the code below.
int i = 1;
foreach (Outlook.Attachment att in oMail.Attachments)
{
SqlCommand cmAttachmentCommand = new SqlCommand
("SP_Add_Outlook_Email_Attachments", sqlConn);
cmAttachmentCommand.CommandType =
CommandType.StoredProcedure;
// Add Parameters to SPROC
cmAttachmentCommand.Parameters.Add(new
SqlParameter("@MailAttachmentID", attachmentID));
cmAttachmentCommand.Parameters.Add(new
SqlParameter("@MailAttachmentNumber", i));
cmAttachmentCommand.Parameters.Add(new
SqlParameter("@MailAttachmentType", 1));
// ## ERROR OCCURS HERE !!!!!
cmAttachmentCommand.Parameters.Add(new
SqlParameter("@BlobField", att));
// Open the connection and execute the Command
cmAttachmentCommand.ExecuteNonQuery();
i++;
}