|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Maximum index on a list is less than the list sizethan 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 On 5/25/2010 10:36 PM, Parag wrote:
Show quoteHide quote > I keep getting "Make sure that the maximum index on a list is less It means there are no "|" in the input string to the split command. > 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 > > 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 "Family Tree Mike" <FamilyTreeM***@ThisOldHouse.com> a écrit dans le message de groupe de discussion : OnmnFDI$KHA.***@TK2MSFTNGP02.phx.gbl... > On 5/25/2010 10:36 PM, Parag wrote: Isn't «|» a separator for commands ? ;-)>> 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). -- Fred fole***@free.fr "Family Tree Mike" wrote: Sorry, if it is dimensioned to 1, then vInfo(0) is the only accessible item.> 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 > . > Mike Hello,
> This is a very simple app that's supposed to invoke a new Outlook Have you tried to check the value for UBound(vInfo) or to look at Command ?> email message, break the command line output using "|" delimiter and > feed it into the To, Subject and Body fields of the email > respectively. 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
Umm.... How to pass a sub into a class......
How do I get back deleted Tab Page DataTable - set a specific row. keep changes are made on datasource. an attempt was made to load a program with an incorrect format Crystal Reports in VB.NET Express Edition Re:Date Time Format Problem RE: Dockable windows Problems with ReportViewer and RDLC How can I manually add rows to datagridview. |
|||||||||||||||||||||||