🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.vbasic
Article #104467

Re: Jak uwierzytelnić serwer smtp wewnątrz kodu?

#104467
From: Ender
Date: Fri, 19 Feb 2010 08:13
47 lines
2795 bytes
Witam
Poniżej kod do wysyłki asynchronicznej:

Sub WyslijPoczte()

        Dim SerwerSMTP As New Net.Mail.SmtpClient("twoj_serwer_smtp", 25)
        Dim Mojadres As New Net.Mail.MailAddress("twojAdres_mailowy")
        Dim OdbiorcyAdres As New Net.Mail.MailAddress(txt_Do.Text)
        Dim Poczta As New Net.Mail.MailMessage(Mojadres, OdbiorcyAdres)
        Poczta.Subject = "temat"

        Poczta.Body = "tekst"
        Dim T As Net.Mail.Attachment
        T = New Net.Mail.Attachment(nazwa_pliku)
        Poczta.Attachments.Add(T)
        SerwerSMTP.Credentials = New 
System.Net.NetworkCredential("twojekonto", "hasło")

        Try
            Dim EE As Object
            EE = Poczta

            AddHandler SerwerSMTP.SendCompleted, AddressOf 
SmtpClient_OnCompleted
            SerwerSMTP.SendAsync(Poczta, EE)

        Catch ex As Exception
            MsgBox("Nie wysłano wiadomości z powodu błędu:" & Chr(10) & 
ex.Message)
        End Try

    End Sub
    Public Sub SmtpClient_OnCompleted(ByVal sender As Object, ByVal e As 
System.ComponentModel.AsyncCompletedEventArgs)
        If e.Cancelled = True Then
            MsgBox("Wiadomość została anulowana")
            Application.Exit()
        End If
        If IsNothing(e.Error) = False Then
            MsgBox("Wystąpił błąd przy wysyłaniu wiadomości")
            Application.Exit()
        Else
            MsgBox("Wiadomosć została wysłana")
            Application.Exit()

        End If
    End Sub
Technical Details
Message-ID: <hllhbg$439$1@atlantis.news.neostrada.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!209.197.12.246.MISMATCH!nx02.iad01.newshosting.com!newshosting.com!newsfeed.neostrada.pl!unt-exc-01.news.neostrada.pl!atlantis.news.neostrada.pl!news.neostrada.pl!not-for-mail
References: <9b9890e3-d0b9-4f22-9212-9836177793fd@q16g2000yqq.googlegroups.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!209.197.12.246.MISMATCH!nx02.iad01.newshosting.com!newshosting.com!newsfeed.neostrada.pl!unt-exc-01.news.neostrada.pl!atlantis.news.neostrada.pl!news.neostrada.pl!not-for-mail
From: "Ender" <ender75@poczta.onet.pl>
Newsgroups: pl.comp.lang.vbasic
Subject: Re: Jak uwierzytelnić serwer smtp
 wewnątrz kodu?
Date: Fri, 19 Feb 2010 09:13:09 +0100
Organization: TP - http://www.tp.pl/
Lines: 49
Message-ID: <hllhbg$439$1@atlantis.news.neostrada.pl>
References: <9b9890e3-d0b9-4f22-9212-9836177793fd@q16g2000yqq.googlegroups.com>
NNTP-Posting-Host: axd134.internetdsl.tpnet.pl
X-Trace: atlantis.news.neostrada.pl 1266567344 4201 83.18.81.134 (19 Feb 2010 08:15:44 GMT)
X-Complaints-To: usenet@news.neostrada.pl
NNTP-Posting-Date: Fri, 19 Feb 2010 08:15:44 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5843
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
X-RFC2646: Format=Flowed; Original
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit