Jump to content
extrme

Buat Email Program Dgn Vb.net

Recommended Posts

asslmkm kwn2 semua

sifoo2 n otai2 semua..

nak tanya ni..

ada saper2 ada coding tuk buat simple emel program guna vb.net visual studi0 2005

acctually da jumpa sket coding dia..

tp at last dia error msg kuar la.

katanya yahoo xauthenticate aper ntah

so xleh process la.

saper2 bleh tolong amatlah dihargai..

thanks..

Share this post


Link to post
Share on other sites

Maksud awak nak buat sendiri dari zero email software dan web sbg medium sprt Yahoo mail dan gmail?

Kalau camtu kene paham dua konsep ni, send and receive. Send menggunakan protocol smtp dan receive meggunakan pop3. Untuk send / hantar tidak sesusah mana sbb MS dah siap buat library untuk anda just menggunakan library tersebut dlm .NET via smtp server dlm IIS. Tetapi jika untuk Receive / Terima, anda kene menggunakan pop3 untuk store inbox dan store kedalam database, dimana prosesnya agak rumit sedikit. Anda perlu tahu socket programming untuk membuat sendiri library / API sendiri sbb MS utk .NET tak provide library untuk tujuan tersebut. Namun ada 3rd party library kat internet yg kebanyakkan nya berbayar dan ada yg free tapi kurang stabil. Jika anda experience programmer anda boleh buat sendiri library untuk pop3 ni menggunakan .NET socket programming, very interesting actually. Kalau anda dah berjaya buat library ni dgn jayanya, dah kira boleh license kan dan jual dlm internet hehe.

Edited by ron

Share this post


Link to post
Share on other sites

thank ron for reply..

actually sy tau tu.. n sy bukn nk buat web based

nk buat app.

simple jer..

macam app ni akan generate jpg file then attch trus nak anta ke emel.

ni contoh coding yg tgh buat. tp xberapa bejaya la..

menggunakan Visual Basic 2005 Express Edition

sapa2 otai bole tolong.

Private Sub send_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles send.Click

'Submit E-Mail on click of Button

Dim theMailMessage As MailMessage = New MailMessage(from.Text, emelto.Text)

Try

'Merge textBox1.Text and textBox2.Text

Dim message1 As String

message1 = "test msg"

'message1 += TextBox2.Text + Environment.NewLine

'Set the property of the message body and subject body

theMailMessage.Body = message1

theMailMessage.Attachments.Add(New Attachment(TextBox6.Text))

theMailMessage.Subject = "E-Mail From Me "

'E-Mail Credentials and Sending

'Dim port As Integer

Dim theClient As SmtpClient = New SmtpClient("smtp.mail.yahoo.com")

Dim theCredential As System.Net.NetworkCredential = New System.Net.NetworkCredential("username", "password")

theClient.Credentials = theCredential

theClient.EnableSsl = True

theClient.Port = 465

theClient.Timeout = 30000

'Send the email

theClient.Send(theMailMessage)

MessageBox.Show(("E-Mail Sent Successfully!" _

+ (Environment.NewLine + "Thank You")), "Confirmation", MessageBoxButtons.OK)

Catch smtpex As SmtpException

MessageBox.Show(("An error occured when trying to send a mail. You appear to be disconnected from the Internet. Pleas" & _

"e confirm that you are connected to the Internet and Resubmit the data. " + smtpex.Message))

Catch ex As System.Exception

MessageBox.Show(("An unexpected error occured. " + ex.Message))

End Try

End Sub

Edited by extrme

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...