Results 1 to 19 of 19

Thread: [RESOLVED] [2005] Sending E-mails won't work

  1. #1

    Thread Starter
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    Resolved [RESOLVED] [2005] Sending E-mails won't work

    I just finished a special file editing program in VB.net 2005 and I wanted to add a Report Bug feature that would allow the user to enter in a message that would be e-mailed to me.

    I already tried googling it and I found that you have to use:
    Imports System.net.Mail

    Well when I use that import VB gives me an error saying it doesn't exist. So then I hunted down the class itself and found this.

    http://www.codeproject.com/KB/vb/VB2...89&tid=2583233

    I tried it and it executed without error but it never sent any mail to me.

    Can anyone help me figure this out? Also if you know of a better way to send simple bug reports across the internet and somehow to my computer (or an online Inbox I can check) then I'm all ears, but the best thing I can think of is e-mail.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: [2005] Sending E-mails won't work

    Are you using an SMTP server address and From address that you actually have access to?

  3. #3

    Thread Starter
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    Re: [2005] Sending E-mails won't work

    I'm not using a From address that I have access too. Can I use the same e-mail that I'm sending it to (myself) for From?

    Also I don't know anything about the SMTP server stuff other than it's involved with sending e-mails from VB.net, so if you could explain it to me I could answer you better.

    EDIT: I went ahead and used my e-mail for both To and From and still no luck.
    Last edited by Vectris; Dec 11th, 2008 at 08:01 PM.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: [2005] Sending E-mails won't work

    The SMTP server is the server that sends the mail. The POP3 server is the server that receives the mail. If you don't use a valid SMTP server address then your mail simply can't be sent. If you don't use a From address that's recognised by your SMTP server it will refuse to send the mail. That's for protection against spammers. Open up your own e-mail client and look at the properties of your account. You should be using that e-mail address as the From address and the corresponding SMTP server address.

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: [2005] Sending E-mails won't work

    Have you read anything besides that Code Project article? You're using new classes so you should have read at least the MSDN documentation for the MailMessage and SmtpClient classes by now. The fact that you may not understand everything you read is not a reason not to read it.

  6. #6

    Thread Starter
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    Re: [2005] Sending E-mails won't work

    Well I glanced at them and didn't think I could find anything. Anyways I went ahead and read through them and some others like credentials, ports, etc.

    And I didn't get anything out of it anyways...

    I do have 2 questions if you can answer them:
    1) What do I do with:
    <system.net>
    <mailSettings>
    <!-- these settings define the mail server settings
    from: the user name from which the email is sent - this is the
    application that is sending the message
    host: the name of your mail server
    userName: the name the application will use to log into the mail server
    password: the password for the above user name -->
    <smtp from="admin@your-domain.com">
    <network host="your-mail-server-name"
    userName="your-user-name"
    password="your-password" />
    </smtp>
    </mailSettings>
    </system.net>

    In the link I gave he says put it in your Web.config file, I have no idea what he's talking about.

    2) In the code there is a Host = "10.10.10.", MSDN said it's the IP that the SMTP will use to go through, should I make it my IP, and if so how do I find it?

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: [2005] Sending E-mails won't work

    You didn't get anything at all from the documentation, despite the fact that there are code examples and an explanation of every single method and property for both the SmtpClient class and the MailMessage class?

    Anyway:
    In the code there is a Host = "10.10.10.", MSDN said it's the IP that the SMTP will use to go through, should I make it my IP, and if so how do I find it?
    I've already addressed that:
    Open up your own e-mail client and look at the properties of your account. You should be using that e-mail address as the From address and the corresponding SMTP server address.
    As for the rest, add a config file to your project and then add that XML code inside the <configuration> tag. Of course, you don't have to store the information in the config file but it means you can change it easily later if need be.

  8. #8

    Thread Starter
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    Re: [2005] Sending E-mails won't work

    I tried the code examples and they don't work. Anything that I have to dim as a SMTPClient is unrecognized. I think it has to do with my Imports System.net.Mail too. If we could fix that I'm sure it'd work.

    As for Host I don't know what your talking about by "e-mail client properties". I use hotmail, if that's what you mean by client then I still don't see what to put as host. MSDN told me Host is an IP, hotmail doesn't give me any IP address that I know of.

    I'll try the XML code though, maybe that will work.

    EDIT: How do I add the .config file to the project? I'm looking it up now on my own but in case you post before I find it.
    Last edited by Vectris; Dec 11th, 2008 at 09:17 PM.

  9. #9
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,160

    Re: [2005] Sending E-mails won't work

    i used "met0555's" gmail SmtpClient submission to send emails with .net

    Maybe you can get something from it as well ... codebank


    HTH

    toe
    Last edited by toecutter; Dec 12th, 2008 at 01:20 AM.

  10. #10
    Hyperactive Member mrmojorisin's Avatar
    Join Date
    Oct 2007
    Location
    London Town Vocation: Garden Cricket Genuis
    Posts
    439

    Re: [2005] Sending E-mails won't work

    Quote Originally Posted by Vectris
    EDIT: How do I add the .config file to the project? I'm looking it up now on my own but in case you post before I find it.
    Web.config is should already be part of your project if you are using visual studio.

  11. #11
    Hyperactive Member mrmojorisin's Avatar
    Join Date
    Oct 2007
    Location
    London Town Vocation: Garden Cricket Genuis
    Posts
    439

    Re: [2005] Sending E-mails won't work

    Quote Originally Posted by Vectris
    As for Host I don't know what your talking about by "e-mail client properties". I use hotmail, if that's what you mean by client then I still don't see what to put as host. MSDN told me Host is an IP, hotmail doesn't give me any IP address that I know of.
    The host is the server you are trying to use to send emails. You can either use the server name or the servers IP address as the host name. Try a search to find the hotmail SMTP server host name. You may have to contact them to find out what it is. I doubt you will be able to use this without being a paying customer though.

  12. #12

    Thread Starter
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    Re: [2005] Sending E-mails won't work

    Quote Originally Posted by toecutter
    i used "met0555's" gmail SmtpClient submission to send emails with .net

    Maybe you can get something from it as well ... codebank
    Thanks, I'll check it out after school.


    Web.config is should already be part of your project if you are using visual studio.
    Ok thanks, but now I need to know how to edit it then. I searched google for everything and all I get is code to editing during the program run-time. I want to edit now, not inside of my program but while I'm making the project. Can't I just choose an Option > Edit .config file? I searched all the menus and couldn't find anything. Thanks for clearing that up though.

    The host is the server you are trying to use to send emails. You can either use the server name or the servers IP address as the host name. Try a search to find the hotmail SMTP server host name. You may have to contact them to find out what it is. I doubt you will be able to use this without being a paying customer though.
    Ah, so I have to use the IP of the hotmail.com server. Thanks I'll look into that too.

    Does anyone know why I don't get the imports.net.email to begin with?

  13. #13
    Hyperactive Member mrmojorisin's Avatar
    Join Date
    Oct 2007
    Location
    London Town Vocation: Garden Cricket Genuis
    Posts
    439

    Re: [2005] Sending E-mails won't work

    Quote Originally Posted by Vectris
    Does anyone know why I don't get the imports.net.email to begin with?
    It's not a standard reference. And you need to use "Imports System.Net.Mail"

    To edit web.config, just double click, or open the file...It can be found in soultion explorer.

  14. #14

    Thread Starter
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    Re: [2005] Sending E-mails won't work

    Quote Originally Posted by mrmojorisin
    It's not a standard reference. And you need to use "Imports System.Net.Mail"

    To edit web.config, just double click, or open the file...It can be found in soultion explorer.
    Do you know how I can get "extra" references? and system.net.email was a typo, I tried the correct one and it doesn't work for me.

    Also my Web.config doesn't show up in the Solution Explorer.

  15. #15
    Hyperactive Member mrmojorisin's Avatar
    Join Date
    Oct 2007
    Location
    London Town Vocation: Garden Cricket Genuis
    Posts
    439

    Re: [2005] Sending E-mails won't work

    You can add reference by going to Website>Add Reference.

    All you will need to do for net.mail is type the following line of code at the very top of you vb.aspx page:

    Code:
    Imports System.Net.Mail
    If you are creating a website in visual sutdios, web.config should be automatically created and will appear in your solution explorer.

  16. #16
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [2005] Sending E-mails won't work

    Am I the only one reading this thread thinking that there is no reason why the OP would have a Web.Config file unless this is an ASP project... and since he hasnt mentioned ASP or web pages once and it is not in the ASP section, I am inclined to believe that it isnt. If he's just making a normal winforms app then he wont have a Web.Config file right?

    Vectris - can you confirm whether or not this is a web site that you are making or is it just a normal windows desktop program (Windows Forms Application) ?


    As for sending an email, yes you need to specify an SMTP server and yes if you are using hotmail then you need to use hotmail's SMTP server... I dont know if they allow public emails to be sent through them though or even where you would find the IP of the hotmail SMTP servers because when you send an email through the web based client for hotmail you dont ever have to set any SMTP settings up as it already knows them - and the same goes for adding a hotmail account to Outlook, you just choose HTTP based email server, select hotmail, and thats it.
    I think giving out (or even selling) a program that relies on the hotmail email servers for part of its functionality is a very bad idea anyway...
    Last edited by chris128; Dec 18th, 2008 at 09:17 AM.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  17. #17
    Hyperactive Member mrmojorisin's Avatar
    Join Date
    Oct 2007
    Location
    London Town Vocation: Garden Cricket Genuis
    Posts
    439

    Re: [2005] Sending E-mails won't work

    Oh no, sorry vactris, i was also having problems with sending mail but in asp .net, thats when i come across this thread! Just assumed it was asp. Well hopefully i didnt completely waste your time! sorry.

  18. #18
    Addicted Member
    Join Date
    Nov 2006
    Location
    Minnesota
    Posts
    235

    Re: [2005] Sending E-mails won't work

    You could use the MAPI Controls. They can send through most default email clients setup on a clients machine.
    If someone has helped you, please make sure to rate them.

  19. #19

    Thread Starter
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    Re: [2005] Sending E-mails won't work

    Quote Originally Posted by chris128
    Vectris - can you confirm whether or not this is a web site that you are making or is it just a normal windows desktop program (Windows Forms Application) ?
    Ya this is just a normal windows desktop app. I'm not doing ASP or anything.

    And as stated in the first post this was simply a tiny add-on that would allow users to "Report a Bug" by clicking a button and sending me a message (the e-mail). It's not at all necessary for the program to function, just something extra I wanted.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width