Napisano: 30 Jan 2012 20:37
Pozdrav drugari.
Pravim aplikaciju koja se sastoji od 3 checkbox-a, 2 textbox-a i jednog button-a.
Ona ce proveravati validnost unesene e-mail adrese i password-a i za uzvrat cu dobijati poruku da li su validni ili ne.
Napomena.Ne zelim da proveravam validnost tako sto cu poslati poruku s tog mail-a sebi,nego da sama aplikacija prepozna dal su username i password prosli kroz smtp port.
Pozdrav.
Evo koda:
Imports System.Net.Mail
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Declare variables
Dim sSelectedSMTPServer As String = ""
Dim iSelectedSMTPPort As Integer
'Check wich email account is selected and provide correct smtp address / port.
Select Case True
Case CheckBox1.Checked
sSelectedSMTPServer = "smtp.gmail.com"
iSelectedSMTPPort = 587
Case CheckBox2.Checked
sSelectedSMTPServer = "smtp.live.com"
iSelectedSMTPPort = 587
Case CheckBox3.Checked
sSelectedSMTPServer = "smtp.mail.yahoo.com"
iSelectedSMTPPort = 465
Case Else
'If no account is selected you will get a message and the program will not attempt to send the email.
MsgBox("Please choose your email service.", vbInformation)
End Select
'For multiple selection
If CheckBox1.Checked And CheckBox2.Checked Then
MsgBox("You must select only one email service.", vbInformation)
ElseIf CheckBox1.Checked And CheckBox3.Checked Then
MsgBox("You must select only one email service.", vbInformation)
ElseIf CheckBox2.Checked And CheckBox3.Checked Then
MsgBox("You must select only one email service.", vbInformation)
ElseIf CheckBox1.Checked And CheckBox2.Checked And CheckBox3.Checked Then
MsgBox("You must select only one email service.", vbInformation)
End If
Exit Sub
Dim SMTP As New SmtpClient
'SSL enabled for outgoing mail.
SMTP.EnableSsl = True
'Get login credentials.
SMTP.Credentials = New System.Net.NetworkCredential(TextBox1.Text, TextBox2.Text)
'SMTP Port that will be used.
SMTP.Port = iSelectedSMTPPort
Try
What???
MsgBox("Successfully logged", MsgBoxStyle.Information, "Report")
Me.Close()
Catch ex As Exception
MsgBox("Unsuccessfully logged", MsgBoxStyle.Exclamation, "Report")
End Try
End Sub
Dopuna: 06 Feb 2012 2:05
Da li je moguce da niko od vas ne zeli(nezna) da mi pomogne oko aplikacije???
Postoji greska pri kraju koda a nikako da je resim.
|