.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 26th, 2004, 01:07 PM
elan22 elan22 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 1 elan22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Angry Can't send effective email in VB.NET

I am tring to send emails in VB.Net application using SMTPMail class.
But my messages only show up in queue folder on my computer and never
show in the actual input box of the recipient.I use aol as net provider and I
did set my SMTPmail.servername to localhost.What am I doing wrong?

Reply With Quote
  #2  
Old June 3rd, 2004, 12:15 PM
arthvader arthvader is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: Where the weather includes brush fires and earthquakes
Posts: 3 arthvader User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
VB.NET e-mail messages

I had a great deal of trouble getting Visual Basic .NET to send e-mail messages. Here is the approach that I stumbled onto. Note that it uses CDO for NTS, not Windows 2000, and dependencies include adodb, CDONTS, Excel, and Office at least.

Sub Main()

'allocate memory for the objects

Dim cn As ADODB.Connection 'connection to database

Dim rsTechs As ADODB.Recordset 'list of technicians etc.

Dim GoForIt As Boolean 'shows whether to process

Dim testString As String

Dim body As String

Dim rsOrders As ADODB.Recordset

Dim cmdExec As ADODB.Command

Dim wks As Excel._Worksheet

Dim wkb As Excel._Workbook

Dim wka As Excel.Application

Dim column, row, records, fldCount, iCol As Integer

Dim path As String





'Instantiate the ADODB connection and recordset objects

cn = New ADODB.Connection

rsTechs = New ADODB.Recordset

cmdExec = New ADODB.Command



'Configure and open the connection

cn.Open("Provider=SQLOLEDB.1;Password= . . . ;Persist Security Info=True;" & _

"User ID= . . . ;Initial Catalog=. . . ;Data Source=. . . ")



'configure the command object

cmdExec.ActiveConnection = cn

'lots of application specific processing here

'Instantiate the email message object

Dim NewMessage As CDONTS.NewMail

NewMessage = New CDONTS.NewMail



'Set NewMessage's parameters that are result independent

NewMessage.To = rsTechs("emailaddress").Value

NewMessage.From = ". . . "

NewMessage.Subject = "Open Work Orders"

NewMessage.MailFormat = CDONTS.CdoMailFormats.CdoMailFormatMime

NewMessage.BodyFormat = CDONTS.CdoBodyFormats.CdoBodyFormatHTML



'Set NewMessage's result-specific parameters

If records = 0 Then

NewMessage.Body = "You have no open work orders. To change your reporting preferences, please reply to this e-mail message and indicate on which weekdays, if any, you would like to receive this report. Thanks. Art."

Else

body = "You have "

If records = 1 Then

body = body & "one open work order."

Else

body = body & records & " open work orders."

End If

body = body & " To change your reporting preferences, please reply to this e-mail message and indicate on which weekdays, if any, you would like to receive this report. Thanks. Art." & vbCrLf & vbCrLf

NewMessage.Body = body



'attach the spreadsheet to the e-mail message

NewMessage.AttachFile(path & "\DailyReport.xls")

End If



'send the e-mail message

NewMessage.Send()



End If







NewMessage = Nothing

rsOrders = Nothing




Reply With Quote
  #3  
Old June 10th, 2004, 07:35 AM
slfrudd slfrudd is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Bradford , UK
Posts: 13 slfrudd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Cant send email in vb.net

I found that if you set the smtp.server as "" It seems to work

Here is a class I used

Code:
Imports System.Web.Mail
Public Class SendAdminMail
    Public Function sendmail(ByVal PID As String, ByVal Name As String, ByVal SQA As String) As String
        Dim response As String
        Dim objMailMessage As MailMessage
        Dim objMailAttachment As MailAttachment
        'Change this to the Smtp server address of website
        Try
            SmtpMail.SmtpServer = ConfigurationSettings.AppSettings("smtpServer")
            ' Create the Mail Message
            objMailMessage = New MailMessage()
            objMailMessage.From = "Admin@SQAIntranet.pace.co.uk"
            objMailMessage.To = ConfigurationSettings.AppSettings("AdminEmail")
            objMailMessage.Subject = "SQA Website email"
            objMailMessage.Body = PID & ", " & Name & ", " & SQA
            objMailMessage.BodyFormat = MailFormat.Text
            ' Send the Mail Message
            SmtpMail.Send(objMailMessage)
        Catch
            response = "Send Mail Failed"
            Return response
        End Try
        Return response
    End Function
End Class


You just need an appsettings tag in your web.config file with the STMP server ip address (or "" if local)

I also found that the queue sits there doing nothing on localhost if there is any kind of error in one of the items queued.

Scott.

Reply With Quote
  #4  
Old June 10th, 2004, 07:46 AM
slfrudd slfrudd is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Bradford , UK
Posts: 13 slfrudd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Cant send email in vb.net

Another approach would be to set the smtp.servername to the ip address of your AOL email server......

Scott.

Reply With Quote
  #5  
Old June 12th, 2004, 11:54 AM
tibby tibby is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 6 tibby User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I found the SMTP class in .Net and CDONTS to be vey annoying and limited. My solution and recommendation is to look up the RFC for SMTP server transmission, and do it that way. I'm currrently working on such a class, but won't be done untill later this week. But, I've found that CDONTS can't talk to anything other than Exchange or basic SMTP very well, and the authentication scheme is very annoying, even though it's a simple Base4 stream.
Anyway, that's my 2cents on it.

Tibby

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > Can't send effective email in VB.NET


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT