Trying to send an eMail frommy vb.net App.
Is there anybody out there that has successfully done this?
I am having major problems and need a step by step guide into the world of
system.web and IIS. The reading I have done(alot) has been pretty useless in
helping me understand the various bits required.
The error I get is: On a pc running win2k with IIS and Lotus Notes
System.Runtime.InteropServices.SEHException: External component has thrown
an Exception
at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Web.Mail.CdoSysHelper.Send(MailMessage message)
at System.Web.Mail/SmtpMail.Send(MailMessage message)
at MyAppName.MyFormName.MyMailingFunction
The error I get is: On a DEV(not networked) pc running winXP with with IIS
but without Lotus Notes
System.Web.HttpException: Could not access 'CDO.Message' object ---->
System.Reflection.TargetInvocationexception: Exception has been thrown by
the target of an invocation --->
System.Runtime.InteropServices.COMException(0x8004 0213): The transport
failed to connect to the server
CODE:::
Imports System.Web.Mail
Private Sub Mail1()
Dim myMessage As New MailMessage
Dim myMailServer As SmtpMail
myMessage.BodyFormat = MailFormat.Text 'or MailFormat.Html
myMessage.Priority = MailPriority.Normal ', High, or Low
myMessage.From = "ma************@quinn-direct.com" 'From Address
myMessage.To = "ma************@quinn-direct.com" 'To Address
'myMessage.Cc = "so*********@somedomain.com" 'Send a Carbon-Copy
'myMessage.Bcc = "so*****@diffdomain.com" 'Send a Blind Carbon-Copy
myMessage.Subject = "VB.NET E-mail Test"
'Below is the Body of the E-mail I did it this way to show that this
property
'can be treated as a string.
myMessage.Body = "This is a test of a Windows E-mailer<BR>" & vbCrLf
myMessage.Body &= "<font color=blue>TEST</font><br>" & vbCrLf & _
"<font color=red>TEST</font><br>" & vbCrLf
'Add an attachment to your Email. Attachments in Windows
applications are touchy.
'In the project it will throw an error if you don’t have the file in
the
'Solution Explorer. But just running the .exe it seems to be fine
with any file.
'Make sure file has full pathing otherwise you will definitely get
an error.
'myMessage.Attachments.Add(New System.Web.Mail.MailAttachment(File))
'10.2.0.4
'cavan02.quinn-direct.com)
'myMailServer.SmtpServer = "cavan02.quinn-direct.com" 'This is your
mail server
myMailServer.SmtpServer = "cn2k-03321.quinn-direct.com" 'This is
your mail server
Try
myMailServer.Send(myMessage)
Catch ex As Exception
MessageBox.Show(ex.ToString)
MessageBox.Show(ex.InnerException.ToString)
MessageBox.Show(ex.Source)
End Try
myMessage = Nothing
End Sub