Results 1 to 13 of 13

Thread: Sending outlook email from vb.net --> RESOLVED

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Location
    Porto Alegre, RS
    Posts
    210

    Sending outlook email from vb.net --> RESOLVED

    anybody have already or know how to send an email from my vb.net application? The program that we use to send and recive emails is Outlook.

    Thank you,
    Guilherme Costa
    Last edited by gccosta; Oct 3rd, 2003 at 02:49 PM.

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    VB Code:
    1. Process.Start("mailto:[email protected]")

  3. #3
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Or, use the system.web.mail namespace.

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by hellswraith
    Or, use the system.web.mail namespace.
    This gonna be messy unless he has a running relay's address server or launching his own SMTP Server .

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Pirate
    This gonna be messy unless he has a running relay's address server or launching his own SMTP Server .
    or online SMTP that accepts your requests to deliever the messages to destination .

  6. #6
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    As long as your from address has a valid account with the smtp server you are sending it from, it has no problems. At least that is my experience. I was able to make a quick and dirty example for someone that was a windows forms application and I sent it through my web hosting mail server with no problems as long as I sent it from a valid email address. I wasn't able to spoof the from address as somone elses (this is a good thing).

    I will try to post an example later tonight, really simple. The added benefit is you can do it all in code by setting the text of the subject, the message body, the to and from address, etc. This makes it transparent to the user which in some cases is the best way to go.

  7. #7
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    hellswraith , could you try this example and see if it works with hotmail accounts . Been trying to no avail . I even posted this in C# section and it worked with some of the guys there .

    http://www.c-sharpcorner.com/Interne...notifierlc.asp

    thanks .

  8. #8
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    I don't have a hotmail account to test it on.


    To send a mail message from a windows forms account, do something like this.

    VB Code:
    1. 'Create the mail message object and set its properties.
    2. Dim theMail As New System.Web.Mail.MailMessage
    3. theMail.To = "[email protected]"
    4. theMail.From = "[email protected]"
    5. theMail.Body = "Whatever text you want."
    6. theMail.Subject = "My subject"
    7.  
    8. 'Set up the SMTP server to use to send the message.
    9. System.Web.Mail.SmtpMail.SmtpServer = "mail.yourmailserverdomain.com"
    10.  
    11. 'Send the mail.
    12. System.Web.Mail.SmtpMail.Send(theMail)

  9. #9
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    this thread is a bit older but I have a question about the namespace.

    when I put the system.web.mail in the imports section, my intelli-sence doesn't recognize the mail part. do I need to add a reference to it?

  10. #10
    Hyperactive Member
    Join Date
    Apr 2003
    Location
    Three Rivers, MI
    Posts
    354
    It has been a while since I did this but I think you need to add System.Web.dll (from the .Net references) to your project to send email from a Windows form.

  11. #11
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    thanks!! i put both that one and the web.mail.services in just to make sure.

    does have a referenced dll in the app make it bigger and if you don't need it, does it slow it down?

  12. #12
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    on another note, how do you get vb to launch the default mail client? I don't want to use shell() cause the path may not always be correct.


    edit: I found a thread on this subject. disregard
    Last edited by Andy; Feb 11th, 2004 at 11:41 AM.

  13. #13
    Member
    Join Date
    Feb 2004
    Location
    LA
    Posts
    57
    I try this code works greater

    Can some one help with adding Attachment?

    I try this code but it gives me and error "Specified cast is not valid"

    Attach = OpenFileDialog1.FileName

    theMail.Attachments.Add(Attach)


    Please help

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