User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 426,394 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,309 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 1553 | Replies: 3 | Solved
Reply
Join Date: Sep 2006
Posts: 17
Reputation: Dhruv Shah is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
Dhruv Shah Dhruv Shah is offline Offline
Newbie Poster

Help Email Sending Problem in ASP.NET

  #1  
Oct 26th, 2006
hello there i want to send an email in which user has selected an attachment to send. below is the code for it:

  1. [color=#0000ff]
  2. Imports[/color][color=#000000] System.Web.Mail[/color]
  3. [color=#0000ff]Public[/color][color=#000000] [/color][color=#0000ff]Class[/color][color=#000000] WebForm1[/color]
  4. [color=#0000ff]Inherits[/color] System.Web.UI.Page
  5. #[color=#0000ff]Region[/color] " Web Form Designer Generated Code "
  6. [color=#008000]'This call is required by the Web Form Designer.
  7. [/color]<System.Diagnostics.DebuggerStepThrough()> [color=#0000ff]Private[/color] [color=#0000ff]Sub[/color] InitializeComponent()
  8. [color=#0000ff]End[/color] [color=#0000ff]Sub
  9. [/color][color=#0000ff]Protected[/color] [color=#0000ff]WithEvents[/color] txtToEmail [color=#0000ff]As[/color] System.Web.UI.WebControls.TextBox
  10. [color=#0000ff]Protected[/color] [color=#0000ff]WithEvents[/color] lbFiles [color=#0000ff]As[/color] System.Web.UI.WebControls.ListBox
  11. [color=#0000ff]Protected[/color] [color=#0000ff]WithEvents[/color] butOK [color=#0000ff]As[/color] System.Web.UI.WebControls.Button
  12. [color=#008000]'NOTE: The following placeholder declaration is required by the Web Form Designer.
  13. [/color][color=#008000]'Do not delete or move it.
  14. [/color][color=#0000ff]Private[/color] designerPlaceholderDeclaration [color=#0000ff]As[/color] System.Object
  15. [color=#0000ff]Private[/color] [color=#0000ff]Sub[/color] Page_Init([color=#0000ff]ByVal[/color] sender [color=#0000ff]As[/color] System.Object, [color=#0000ff]ByVal[/color] e [color=#0000ff]As[/color] System.EventArgs) [color=#0000ff]Handles[/color] [color=#0000ff]MyBase[/color].Init
  16. [color=#008000]'CODEGEN: This method call is required by the Web Form Designer
  17. [/color][color=#008000]'Do not modify it using the code editor.
  18. [/color]InitializeComponent()
  19. [color=#0000ff]End[/color] [color=#0000ff]Sub
  20. [/color]#[color=#0000ff]End[/color] [color=#0000ff]Region
  21. [/color][color=#0000ff]Private[/color] [color=#0000ff]Sub[/color] Page_Load([color=#0000ff]ByVal[/color] sender [color=#0000ff]As[/color] System.Object, [color=#0000ff]ByVal[/color] e [color=#0000ff]As[/color] System.EventArgs) [color=#0000ff]Handles[/color] [color=#0000ff]MyBase[/color].Load
  22. [color=#008000]'Put user code to initialize the page here
  23. [/color][color=#0000ff]End[/color] [color=#0000ff]Sub
  24. [/color][color=#0000ff]Private[/color] [color=#0000ff]Sub[/color] butOK_Click([color=#0000ff]ByVal[/color] sender [color=#0000ff]As[/color] System.Object, [color=#0000ff]ByVal[/color] e [color=#0000ff]As[/color] System.EventArgs) [color=#0000ff]Handles[/color] butOK.Click
  25. [color=#0000ff]Dim[/color] TheMailMessage [color=#0000ff]As[/color] [color=#0000ff]New[/color] MailMessage
  26. [color=#0000ff]Dim[/color] TheMailConnection [color=#0000ff]As[/color] SmtpMail
  27. [color=#0000ff]Dim[/color] TheAttachment [color=#0000ff]As[/color] MailAttachment
  28. [color=#0000ff]Dim[/color] TheItem [color=#0000ff]As[/color] ListItem
  29. TheMailMessage.From = "shahdhruv47@yahoo.com"
  30. TheMailMessage.To = txtToEmail.Text
  31. TheMailMessage.Subject = "File Request"
  32. TheMailMessage.Body = "Attached is the information " _
  33. & "you requested."
  34. [color=#0000ff]For[/color] [color=#0000ff]Each[/color] TheItem [color=#0000ff]In[/color] lbFiles.Items
  35. [color=#0000ff]If[/color] TheItem.Selected = [color=#0000ff]True[/color] [color=#0000ff]Then
  36. [/color]TheAttachment = [color=#0000ff]New[/color] MailAttachment( _
  37. Server.MapPath("/Email/C9/" & TheItem.Value))
  38. TheMailMessage.Attachments.Add(TheAttachment)
  39. [color=#0000ff]End[/color] [color=#0000ff]If
  40. [/color][color=#0000ff]Next
  41. [/color]TheMailConnection.Send(TheMailMessage)
  42. [color=#0000ff]End[/color] [color=#0000ff]Sub
  43. End[/color][color=#000000] [/color][color=#0000ff]Class
  44. [/color]
  45.  
  46.  

and i am getting this error...........

Server Error in '/Email' Application.

The "SendUsing" configuration value is invalid.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: The "SendUsing" configuration value is invalid.

Source Error:

Line 46: End IfLine 47: NextLine 48: TheMailConnection.Send(TheMailMessage)Line 49: End SubLine 50: End Class
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2006
Posts: 84
Reputation: web_developer is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 1
web_developer web_developer is offline Offline
Junior Poster in Training

Re: Email Sending Problem in ASP.NET

  #2  
Oct 30th, 2006
dude may be the problem coz u didnt add the next line to ur code.

SmtpMail.SmtpServer = "name of ur smtp server and often is localhost"

try that

sam
Reply With Quote  
Join Date: Sep 2006
Posts: 17
Reputation: Dhruv Shah is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
Dhruv Shah Dhruv Shah is offline Offline
Newbie Poster

Re: Email Sending Problem in ASP.NET

  #3  
Oct 30th, 2006
Originally Posted by web_developer View Post
dude may be the problem coz u didnt add the next line to ur code.

SmtpMail.SmtpServer = "name of ur smtp server and often is localhost"

try that

sam


thank you so much. Now i am able to send mails, but the problem i noticed is that the mail is going to the BULK folder of the person whose email address i am writing in TO field, and also when i specified CC field and a email address then mail goes to the INBOX folder. What is the reason behind this.Plz.
So do you have any solution for this.
Last edited by Dhruv Shah : Oct 30th, 2006 at 2:11 pm.
Reply With Quote  
Join Date: Mar 2006
Posts: 84
Reputation: web_developer is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 1
web_developer web_developer is offline Offline
Junior Poster in Training

Re: Email Sending Problem in ASP.NET

  #4  
Oct 31st, 2006
dude

ofcourse the mail will reach the bulk mail because ur server isnt known to the server u r sending the mail.

u can do the thing to make the mail goes directly to the inbox but i dont know it and i heard it ****ing hard. u have to play with some protocols and other shits.
my advice to u is to be happy with wht u got.

sam
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 1:12 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC