Qualcuno mi può aiutare?
Vorrei verificare se ci sono nuove mail nella mia casella di posta elettronica (di tipo imap) con un programma in VB6 fatto da me.
Ho visto, cercando su internet, che questa cosa forse non è possibile.
Allora ho pensato che prima di tutto era necessario partire dalle cose più semplici, come ad esempio spedire una mail da un account che sfrutta il pop3. Ma ho trovato dei problemi. Ho provato con WINSOCK e con CDOSYS.
In entrambi i casi non ci sono riuscito.
Mi piacerebbe non dover ricorrere al componente MAPI in quanto dovrei passare per outlook.
Come posso fare?
Il codice che ho utilizzato con WINSOCK è il seguente:
codice:
Dim Reciever As Boolean
Dim Sender As Boolean
Dim MailStat As Boolean
Dim SendStat As Integer
Dim MailServer As String
Private Sub Command1_Click()
GetReady
Winsock1.Connect MailServer, 25
SendStat = 1
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command3_Click()
txtrecieve.Text = "giorgio@modatex.it"
txtsender.Text = "giobex@libero.it"
txtsubject.Text = "test oggetto"
txtmessage.Text = "ci proviamo di nuovo"
End Sub
Private Sub Form_Load()
MailServer = "ceisystems.it"
Reciever = False
Sender = False
GetReady
End Sub
Private Sub txtRecieve_GotFocus()
If Reciever = False Then
txtrecieve.Text = ""
Reciever = True
End If
End Sub
Private Sub txtSender_GotFocus()
If Sender = False Then
txtsender.Text = ""
Sender = True
End If
End Sub
Function GetReady()
Do While Winsock1.State <> sckClosed
DoEvents
Winsock1.Close
Loop
End Function
Private Sub Winsock1_Connect()
txtstatus.Text = "Connected.." & vbNewLine
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim Data As String
Winsock1.GetData Data
txtstatus.SelLength = Len(txtstatus.Text)
txtstatus.SelText = Data
Select Case SendStat
Case 1
Winsock1.SendData "HELO yahoo.com" & vbCrLf
Case 2
Winsock1.SendData "MAIL FROM: " & txtsender.Text & vbCrLf
Case 3
Winsock1.SendData "RCPT TO: " & txtrecieve.Text & vbCrLf
Case 4
Winsock1.SendData "DATA" & vbCrLf
Winsock1.SendData "subject: " & txtsubject.Text & vbCrLf
Winsock1.SendData txtmessage.Text & vbCrLf
Case 5
Winsock1.SendData vbCrLf & "." & vbCrLf
Case 6
Winsock1.SendData "QUIT" & vbCrLf
End Select
SendStat = SendStat + 1
End Sub
Come mai se metto winsock1.connect in un button non si connette (e winsock1.state mi da 6) mentre se lo metto nel form_load si connette (e winsock1.state mi da 7) ma comunque non spedisce nulla?
Invece il codice che ho usato con CDOSYS è questo:
codice:
Set objMail = New CDO.Message
objMail.To = "me@gmail.com"
objMail.From = "me@alice.it"
objMail.Subject = "Oggetto mail"
Message = "Messaggio"
objMail.TextBody = Message
objMail.Send
Set objMail = Nothing
Perché (in tutti i codici che ho provato con CDOSYS) mi da quest'errore: il valore di configurazione "sendusing" non è valido?
grazie.