Odesílání SMS   otázka

VB.NET

Mám jeden skript pro odesílání SMS zpráv, vše se odešle a rozdělí, ale vypíše to chybu hned po odeslání ...

Samotný skript:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
.... .... .... .... ...
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Send(TextBox1.Text, RichTextBox1.Text)
    End Sub
 
    Private Const SmsLength = 43
    Private Sub Send([to] As String, sms As String)
        Using client = New SmtpClient("smtp.gmail.com", 587)
            client.EnableSsl = True
            client.Credentials = New NetworkCredential("piskoviste@gmail.com", "heslo")
            For index = 0 To sms.Length Mod SmsLength
                client.Send("piskoviste@gmail.com", String.Format("+420{0}@sms.cz.o2.com", [to]), String.Empty, sms.Substring2(index * SmsLength, SmsLength))
            Next
        End Using
    End Sub
 
End Class
 
Module ExtensionMethods
 
    <Extension()> _
    Public Function Substring2(input As String, index As Integer) As String
        If index < 0 Then
            Return input.Substring(input.Length + index, -index)
        Else
            Return input.Substring(index, input.Length - index)
        End If
    End Function
 
    <Extension()> _
    Public Function Substring2(input As String, index As Integer, length As Integer) As String
        Dim index2 = index + length
        If index2 > input.Length Then
            length = input.Length Mod length
        End If
        Return input.Substring(index, length) 'Error
    End Function
 
End Module

A ten error co to vyhazuje:Hodnota startIndex nemůže být větší než délka řetězce.

Název parametru: startIndex

Obsah TextBoxu1 736487156

Obsah RichTextBoxu1 Zkouska Zkouska Zkouska Zkouska Zkouska Zkouska Zkouska Zkouska Zkouska Zkouska Zkouska Zkouska Zkouska Zkouska

nahlásit spamnahlásit spam 0 odpovědětodpovědět

přihlásit pomocí externího účtu

přihlásit pomocí jména a hesla

Uživatel:
Heslo:

zapomenuté heslo

 

založit nový uživatelský účet

zaregistrujte se

 
zavřít

Nahlásit spam

Opravdu chcete tento příspěvek nahlásit pro porušování pravidel fóra?

Nahlásit Zrušit

Chyba

zavřít

feedback