PC Review


Reply
Thread Tools Rate Thread

Attachment Collection Problem !!!

 
 
W Akthar
Guest
Posts: n/a
 
      6th Jan 2005
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++;
}
 
Reply With Quote
 
 
 
 
W Akthar
Guest
Posts: n/a
 
      6th Jan 2005
Problem solved !!


>-----Original Message-----
>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++;
>}
>.
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find out a relation between the embedded images and the attachment collection of an email DPM Microsoft Outlook VBA Programming 4 22nd Nov 2008 12:58 PM
Attachment Problem - different file name, same attachment Disco Stu Microsoft Outlook Discussion 2 1st Apr 2008 02:35 AM
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Øyvind Isaksen Microsoft ASP .NET 1 18th May 2007 10:24 AM
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Øyvind Isaksen Microsoft Dot NET 1 18th May 2007 10:24 AM
key/value collection that allows key string to be updated and retains collection item entry order dx Microsoft Dot NET Framework 2 25th Sep 2004 05:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:42 PM.