Elektron pochta serveri yordamida ishlovchi mijoz dasturini yaratish



Download 1,88 Mb.
Pdf ko'rish
bet8/8
Sana06.04.2022
Hajmi1,88 Mb.
#531885
1   2   3   4   5   6   7   8
Bog'liq
elektron pochta serveri yordamida ishlovchi mijoz dasturini yaratish


partial
class
Form1

Form

public
Form1(){ 
InitializeComponent(); 

public
string
line1; 
private
void
Form1_Load(
object
sender, 
EventArgs
e){ 
Service_CB.SelectedIndex = 0; 
chaqir(); 
string
Spcmd; 
OleDbConnection
cnn = 
new
OleDbConnection
(
@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
+ line1); 
OleDbCommand
cmd = 
new
OleDbCommand
(); 
cmd.Connection = cnn; 
cmd.CommandType = 
CommandType
.Text; 
Spcmd = 
"select pochta from dust "

cmd.CommandText = Spcmd; 
OleDbDataAdapter
da = 
new
OleDbDataAdapter
(cmd); 
DataTable
dt = 
new
DataTable
(); 
da.Fill(dt); 
RecipientEmail_TB.DataSource = dt; 
RecipientEmail_TB.DisplayMember = 
"pochta"


private
void
chaqir() 

string
Spcmd; 
OleDbConnection
cnn = 
new
OleDbConnection
(
@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
+ line1); 
OleDbCommand
cmd = 
new
OleDbCommand
(); 


58 
cmd.Connection = cnn; 
cmd.CommandType = 
CommandType
.Text; 
Spcmd = 
string
.Format(
"select id,mailnomi from foydalan where indeks={0}"

Service_CB.SelectedIndex + 1); 
cmd.CommandText = Spcmd; 
OleDbDataAdapter
da = 
new
OleDbDataAdapter
(cmd); 
DataTable
dt = 
new
DataTable
(); 
da.Fill(dt); 
SenderEmail_TB.DataSource = dt; 
SenderEmail_TB.DisplayMember = 
"mailnomi"


private
void
Send_Button_Click(
object
sender, 
EventArgs
e){ 
if
(Service_CB.SelectedIndex == 0){
//localhost
using
(
MailMessage
mm = 
new
MailMessage
(SenderName_TB.Text + 
" <"

SenderEmail_TB.Text + 
">"
, RecipientEmail_TB.Text)){ 
mm.Subject = Subject_TB.Text; 
mm.Body = MailText_TB.Text; 
mm.IsBodyHtml = IsHTML_CB.Checked; 
using
(
SmtpClient
sc = 
new
SmtpClient
(
"127.0.0.1"
)){ 
sc.Send(mm); 


}
else
if
(Service_CB.SelectedIndex == 1){
//Gmail
using
(
MailMessage
mm = 
new
MailMessage
(SenderName_TB.Text + 
" <"

SenderEmail_TB.Text + 
">"
, RecipientEmail_TB.Text)){ 
mm.Subject = Subject_TB.Text; 
mm.Body = MailText_TB.Text; 
mm.IsBodyHtml = IsHTML_CB.Checked; 
using
(
SmtpClient
sc = 
new
SmtpClient
(
"smtp.gmail.com"
, 587)){ 
sc.EnableSsl = 
true

sc.DeliveryMethod = 
SmtpDeliveryMethod
.Network; 
sc.UseDefaultCredentials = 
false

sc.Timeout = 30000; 
sc.Credentials = 
new
NetworkCredential
(SenderEmail_TB.Text, 
AccountPassword_TB.Text); 
sc.Send(mm); 


}
else
if
(Service_CB.SelectedIndex == 2){
//Yandex
using
(
MailMessage
mm = 
new
MailMessage
(SenderName_TB.Text + 
" <"

SenderEmail_TB.Text + 
">"
, RecipientEmail_TB.Text)){ 


59 
mm.Subject = Subject_TB.Text; 
mm.Body = MailText_TB.Text; 
mm.IsBodyHtml = IsHTML_CB.Checked; 
using
(
SmtpClient
sc = 
new
SmtpClient
(
"smtp.yandex.ru"
, 25)){ 
sc.EnableSsl = 
true

sc.DeliveryMethod = 
SmtpDeliveryMethod
.Network; 
sc.UseDefaultCredentials = 
false

sc.Timeout = 30000; 
sc.Credentials = 
new
NetworkCredential
(SenderEmail_TB.Text, 
AccountPassword_TB.Text); 
sc.Send(mm); 


}
else
if
(Service_CB.SelectedIndex == 3){
//Mail.ru
using
(
MailMessage
mm = 
new
MailMessage
(SenderName_TB.Text + 
" <"

SenderEmail_TB.Text + 
">"
, RecipientEmail_TB.Text)){ 
mm.Subject = Subject_TB.Text; 
mm.Body = MailText_TB.Text; 
mm.IsBodyHtml = IsHTML_CB.Checked; 
using
(
SmtpClient
sc = 
new
SmtpClient
(
"smtp.mail.ru"
, 25)){ 
sc.EnableSsl = 
true

sc.DeliveryMethod = 
SmtpDeliveryMethod
.Network; 
sc.UseDefaultCredentials = 
false

sc.Timeout = 30000; 
sc.Credentials = 
new
NetworkCredential
(SenderEmail_TB.Text, 
AccountPassword_TB.Text); 
sc.Send(mm); 




private
void
Service_CB_SelectedIndexChanged(
object
sender, 
EventArgs
e){ 
AccountPassword_TB.Enabled = Service_CB.SelectedIndex != 0; 
chaqir(); 

private
void
MailText_TB_TextChanged(
object
sender, 
EventArgs
e) 


private
void
IsHTML_CB_CheckedChanged(
object
sender, 
EventArgs
e) 


60 


private
void
Form1_FormClosing(
object
sender, 
FormClosingEventArgs
e) 


private
void
dust_Click(
object
sender, 
EventArgs
e) 

formm.
dustlar
fd = 
new
formm.
dustlar
(); 
fd.path = line1; 
fd.Show(); 

private
void
foydalan_Click(
object
sender, 
EventArgs
e) 

formm.
foydalan
df = 
new
formm.
foydalan
(); 
df.path = line1; 
df.Show(); 

private
void
AccountPassword_TB_TextChanged(
object
sender, 
EventArgs
e) 





Download 1,88 Mb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish