Advertisement
Advertisement
| 07.15.2008 at 03:05PM PDT, ID: 23567816 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: |
.NET code:
Imports System
Imports System.Net.Mail
Imports System.Runtime.InteropServices
Namespace sscemail
<Guid("893F6A58-52B1-11DD-8B0C-046D56D89593"), _
InterfaceType(ComInterfaceType.InterfaceIsIDispatch)> _
Public Interface _smtp
<DispId(1)> Function sendmail(ByVal fromAddress As String, ByVal displayName As String, ByVal toAddress As String, ByVal subject As String, ByVal body As String, ByVal html As Boolean, ByVal username As String, ByVal password As String, ByVal host As String, ByVal port As Integer, ByVal enablessl As Boolean) As Boolean
End Interface
<Guid("3ce1d9b0-52b7-11dd-ae16-0800200c9a66"), _
ClassInterface(ClassInterfaceType.None), _
ProgId("sscemail.smtp")> Public Class smtp
Implements _smtp
Public smtp()
Public Function sendmail(ByVal fromAddress As String, ByVal displayName As String, ByVal toAddress As String, ByVal subject As String, ByVal body As String, ByVal html As Boolean, ByVal username As String, ByVal password As String, ByVal host As String, ByVal port As Integer, ByVal enablessl As Boolean) As Boolean Implements _smtp.sendmail
Dim msg As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage()
msg.To.Add(toAddress)
msg.From = New MailAddress(fromAddress, displayName, System.Text.Encoding.UTF8)
msg.Subject = subject
msg.SubjectEncoding = System.Text.Encoding.UTF8
msg.Body = body
msg.BodyEncoding = System.Text.Encoding.UTF8
msg.IsBodyHtml = html
msg.Priority = MailPriority.Normal
'Add the Credentials
Dim client As SmtpClient = New SmtpClient()
client.Credentials = New System.Net.NetworkCredential(username, password)
client.Port = port 'or use 465
client.Host = host
client.EnableSsl = enablessl
Try
client.Send(msg)
Catch ex As Exception
Return False
End Try
Return True
End Function
End Class
End Namespace
VB6 code:
Option Explicit
Private Sub cmdSend_Click()
Dim a As sscemail.smtp
a = New sscemail.smtp
MsgBox (a.sendmail("jon@xxx.com", "Jon Califf", "curdie@xxx.com", "Hello this is a test.", "Only testing.", False, "jon@xxx.com", "password", "smtp.gmail.com", 587, True))
End Sub
|