Dim AttachmentFiles As ArrayList = Nothing
Private Sub Send_Mail()
Try
Dim email As New MailMessage
With email
.From = New MailAddress("
[email protected]")
.To.Add(email_to.Text)
.CC.Add(email_cc.Text)
.Bcc.Add(email_bcc.Text)
.Subject = email_sub.Text
.Body = email_body.Text
.IsBodyHtml = True
.Priority = MailPriority.Normal
End With
Dim basicAuthenticationInfo As New System.Net.NetworkCredential("
[email protected]", "my_password")
Dim sC As New SmtpClient()
With sC
.Port = 587
.Host = "smtp.gmail.com"
.UseDefaultCredentials = False
.Credentials = basicAuthenticationInfo
.EnableSsl = True
End With
Dim iCnt As Integer
If Not AttachmentFiles Is Nothing Then
iCnt = AttachmentFiles.Count - 1
For i = 0 To iCnt
If FileExists(AttachmentFiles(i)) Then
email.Attachments.Add(AttachmentFiles(i))
End If
Next
End If
sC.Send(email)
MsgBox("Αποστολή επιτυχής!" & vbCrLf)
Catch ex As Exception
MsgBox("Αποστολή ανεπιτυχής!" & vbCrLf & ex.Message)
End Try
End Sub
Private Function FileExists(ByVal FileFullPath As String) As Boolean
If Trim(FileFullPath) = "" Then Return False
Dim f As New IO.FileInfo(FileFullPath)
Return f.Exists
End Function
Το Code Snippet δεν ενιωθε! Ωρίστε και ο κώδικας για VB.
No knowledge can be certain, if it is not based
upon mathematics or upon some other knowledge
which is itself based upon the mathematical
sciences.