Title: Please help me: cant read the mail with attechment

when i read an email with parameters for the password, a title and a text in the body (for example with a mail from handy), that goes perfect. but if i want to send the mail with an attachment, i had this error:

Laufzeitfehler in Microsoft VBScript error '800a0009'

Index au�erhalb des g�ltigen Bereichs: '[number: 1]'
/blog/receiveMail_test_mitbild.asp, line 59

when i write out the msg.Body i got this:  MessageID = 338401608
                                                        msg.Body =      ��ࡱ�

here is my code:
<%
Set DBConnection = Server.CreateObject("ADODB.Connection")
DBConnection.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Password=;Initial Catalog=demo;Data Source=server"

SQL = "SELECT cUserBlogname,cUserPasswort FROM BlogUser"

Set RS = Server.CreateObject("ADODB.RecordSet")
RS.Open SQL, DBConnection

Do while not RS.EOF
    Set pop3 = Server.CreateObject( "JMail.POP3" )
    pop3.Connect "mailadress", "password", "server"

    i = pop3.count

    do while i > 0
        Set msg = pop3.Messages.item(i)
        TmpStr = pop3.GetMessageUID(i)

    ReTo = ""
    ReCC = ""

    Set Recipients = msg.Recipients
        separator = ", "

    For recipCount = 0 To Recipients.Count - 1
        If recipCount = Recipients.Count - 1 Then
            separator = ""
        End If

        Set re = Recipients.item(recipCount)
        If re.ReType = 0 Then
            ReTo = ReTo & re.Name & re.EMail & separator
        else
            ReCC = ReTo & re.Name & re.EMail & separator
        End If
    Next
    BodyString = msg.Body

    MailString = REPLACE(REPLACE(REPLACE(BodyString, "#PW#", "" ), "#H#", ";;" ), "#T#",";;" )

    dataarray=SPLIT(MailString,";;")

    pw = dataarray(0)
    title = dataarray(1) == here is the error, line 59
    longtext = dataarray(2)

    Set DatabaseConnection = Server.CreateObject("ADODB.Connection")
    DatabaseConnection.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Password=;Initial Catalog=demo;Data Source=server"

         Set Attachments = msg.Attachments
          separator = ", "

         For i = 0 To Attachments.Count - 1
           If i = Attachments.Count - 1 Then
             separator = ""
           End If

            Set at = Attachments(i)
            at.SaveToFile("http://path/blog/images/" & at.Name)
         Next

    Set RSUser = Server.CreateObject("ADODB.RecordSet")
    RSUser.Open SQLUser, DatabaseConnection

    SQLUser = "INSERT INTO TestMail (nUserID,cName,cEmpfaenger,cTitle,cLongText,dDatum,cAttachmentName,cAttachmentSize) VALUES (" & RSUser("nUserID") & ",'" & msg.From & "','" & ReTo & "','" & title & "','" & longtext & "','" & msg.Date & "','" & attachmentName & "','" & attachmentSize & "')"

    DatabaseConnection.Execute(SQLUser)

    pop3.DeleteSingleMessage(i)

    DatabaseConnection.Close

    set msg=nothing
        i = i -1
    loop

    pop3.Disconnect
    RS.MoveNext
loop
%>

thanks for your help and best regards,

andy

Reply via email to