Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Module SendSMTP
- Public Sub SendSMTP(ByVal strFrom As String, ByVal strTo As String, ByVal strSubject As String, ByVal strBody As String, ByVal strCC As String, ByVal strAttachments As String)
- Dim insMail As New MailMessage(New MailAddress(strFrom), New MailAddress(strTo))
- With insMail
- .Subject = strSubject
- .Body = strBody
- .CC.Add(New MailAddress(strCC))
- If Not strAttachments.Equals(String.Empty) Then
- Dim strFile As String
- Dim strAttach() As String = strAttachments.Split(";"c)
- For Each strFile In strAttach
- .Attachments.Add(New Attachment(strFile.Trim()))
- Next
- End If
- End With
- Dim SmtpUser As New System.Net.NetworkCredential()
- Dim smtp As New System.Net.Mail.SmtpClient
- '-- Define Authenticated User
- SmtpUser.UserName = "something"
- SmtpUser.Password = "somepassword"
- SmtpUser.Domain = "smtp.1und1.de"
- '-- Send Message
- smtp.UseDefaultCredentials = False
- smtp.Credentials = SmtpUser
- smtp.Port = 25
- smtp.Send(insMail)
- End Sub
- End Module
- 'error
- SendSMTP("something@something.de", "flo@flo.de", "Subject", "Body here", "CC", "Attachment")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement