From: Parag on
I keep getting "Make sure that the maximum index on a list is less
than the list size" on the line "olItem.Subject = vInfo(1)" - any
clues on what the issue maybe?

This is a very simple app that's supposed to invoke a new Outlook
email message, break the command line output using "|" delimiter and
feed it into the To, Subject and Body fields of the email
respectively.

Module SendEmail

Public Sub Main()

Dim myOleApp As Microsoft.Office.Interop.Outlook.Application
Dim olItem As Microsoft.Office.Interop.Outlook.MailItem
Dim vInfo As Array

' Assume Command line parameter is text separated by "|"
vInfo = Split(Command, "|")

' Create Outlook instance and a mail item
myOleApp = New Microsoft.Office.Interop.Outlook.Application
olItem =
myOleApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)

' Fill in To, Subject and Message
olItem.To = vInfo(0)
olItem.Subject = vInfo(1)
olItem.Body = vInfo(2)

'Actually send the email
olItem.Send()

' Tidy up
olItem = Nothing
myOleApp = Nothing

End Sub

End Module


From: Family Tree Mike on
On 5/25/2010 10:36 PM, Parag wrote:
> I keep getting "Make sure that the maximum index on a list is less
> than the list size" on the line "olItem.Subject = vInfo(1)" - any
> clues on what the issue maybe?
>
> This is a very simple app that's supposed to invoke a new Outlook
> email message, break the command line output using "|" delimiter and
> feed it into the To, Subject and Body fields of the email
> respectively.
>
> Module SendEmail
>
> Public Sub Main()
>
> Dim myOleApp As Microsoft.Office.Interop.Outlook.Application
> Dim olItem As Microsoft.Office.Interop.Outlook.MailItem
> Dim vInfo As Array
>
> ' Assume Command line parameter is text separated by "|"
> vInfo = Split(Command, "|")
>
> ' Create Outlook instance and a mail item
> myOleApp = New Microsoft.Office.Interop.Outlook.Application
> olItem =
> myOleApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)
>
> ' Fill in To, Subject and Message
> olItem.To = vInfo(0)
> olItem.Subject = vInfo(1)
> olItem.Body = vInfo(2)
>
> 'Actually send the email
> olItem.Send()
>
> ' Tidy up
> olItem = Nothing
> myOleApp = Nothing
>
> End Sub
>
> End Module
>
>

It means there are no "|" in the input string to the split command.
Perhaps vInfo is only dimensioned to 1, so the only accessible item is
vInfo (1).

Note, if there is one "|" in the input string, you would get the error
referencing vInfo (2). You should check the dimension of vINfo before
using the data in it.

--
Mike
From: Fred on


"Family Tree Mike" <FamilyTreeMike(a)ThisOldHouse.com> a �crit dans le
message de groupe de discussion :
OnmnFDI$KHA.420(a)TK2MSFTNGP02.phx.gbl...
> On 5/25/2010 10:36 PM, Parag wrote:

>> I keep getting "Make sure that the maximum index on a list is less
>> than the list size" on the line "olItem.Subject = vInfo(1)" - any
>> clues on what the issue maybe?

>> ' Assume Command line parameter is text separated by "|"
>> vInfo = Split(Command, "|")

> It means there are no "|" in the input string to the split command.
> Perhaps vInfo is only dimensioned to 1, so the only accessible item is
> vInfo (1).

Isn't �|� a separator for commands ? ;-)

--
Fred
foleide(a)free.fr

From: Patrice on
Hello,

> This is a very simple app that's supposed to invoke a new Outlook
> email message, break the command line output using "|" delimiter and
> feed it into the To, Subject and Body fields of the email
> respectively.

Have you tried to check the value for UBound(vInfo) or to look at Command ?

Rather than using a custom delimiter, my personal preference would be to use
http://msdn.microsoft.com/en-us/library/system.environment.getcommandlineargs.aspx
that does this for you (AFAIK the separator is the blank and you can have
spaces inside an argument by enclosing it within ").

--
Patrice




From: Family Tree Mike on


"Family Tree Mike" wrote:

> It means there are no "|" in the input string to the split command.
> Perhaps vInfo is only dimensioned to 1, so the only accessible item is
> vInfo (1).
>
> --
> Mike
> .
>

Sorry, if it is dimensioned to 1, then vInfo(0) is the only accessible item.

Mike