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
Printable View
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
VB Code:
Process.Start("mailto:[email protected]")
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 .Quote:
Originally posted by hellswraith
Or, use the system.web.mail namespace.
or online SMTP that accepts your requests to deliever the messages to destination .Quote:
Originally posted by Pirate
This gonna be messy unless he has a running relay's address server or launching his own SMTP Server .
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.
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 .
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:
'Create the mail message object and set its properties. Dim theMail As New System.Web.Mail.MailMessage theMail.To = "[email protected]" theMail.From = "[email protected]" theMail.Body = "Whatever text you want." theMail.Subject = "My subject" 'Set up the SMTP server to use to send the message. System.Web.Mail.SmtpMail.SmtpServer = "mail.yourmailserverdomain.com" 'Send the mail. System.Web.Mail.SmtpMail.Send(theMail)
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?
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.
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?
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
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 :confused: