|
-
Mar 15th, 2008, 05:50 PM
#1
Thread Starter
Frenzied Member
[2005] Email
How do i make it so when a button is clicked the text of a textbox is sent as a email to a certain address?????
Don't give links to other threads since none of them explain because i want VISUAL BASIC 2005. Please leave an example...
Thankyou
-
Mar 15th, 2008, 07:31 PM
#2
Hyperactive Member
Re: [2005] Email
First of all you need an smtp server to work on. You can't just send an e-mail from nothing.
I suggest that you make an e-mail account on bluebottle.com or any e-mail that has POP3/smtp (not hotmail) and find out their smtp.
I have some code that can send an e-mail i just have to find it.
Cameron.
-
Mar 15th, 2008, 07:58 PM
#3
Hyperactive Member
Re: [2005] Email
Here's the code:
1. add about 4 textboxes to your form.
2. add a button
Dim mail as new system.web.mail.mailmessage
"Button click sub here"
SmtpMail.SmtpServer = "Yoursmtpserver, Password"
mail = new MailMessage()
mail.To = Textbox1.text
mail.From = Textbox2.Text
mail.Subject = Textbox3.text
mail.Body = textbox4.text
SmtpMail.Send(mail)
End sub()
This code should work if not post the error and i will try and fix it.
Cameron
-
Mar 15th, 2008, 08:26 PM
#4
Fanatic Member
Re: [2005] Email
Sorry to say but camerons code will most likely not work. You'll have to use SMTP. Your ISP provides a SMTP for you to use.
Alternatively you can signup for google's gmail, and use their SMTP server.
Most liekly you'll need to login using credentials.
-
Mar 15th, 2008, 09:18 PM
#5
Thread Starter
Frenzied Member
Re: [2005] Email
 Originally Posted by masfenix
Sorry to say but camerons code will most likely not work. You'll have to use SMTP. Your ISP provides a SMTP for you to use.
Alternatively you can signup for google's gmail, and use their SMTP server.
Most liekly you'll need to login using credentials.
I dont quite understand.... So the reason i wanted to know how to do email is because im making a asp.net website and im making it in visual basic so i want to make a contact us page. I need to know how to do email.
-
Mar 15th, 2008, 09:20 PM
#6
Fanatic Member
Re: [2005] Email
Most SMTP servers require you to login.
edit: I know this is in C#.Net but it can be converted VERY EASILY.. all it does is use the .net Email classes
vb Code:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net.Mail;
using System.Net;
public partial class sendmail : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SmtpClient smtpClient = new SmtpClient();
MailMessage message = new MailMessage();
try
{
smtpClient.Host = "72.18.138.246"; //or mail.domain-name.com
//Default port will be 25
smtpClient.Port = 25;
NetworkCredential info = new NetworkCredential(" [email protected]", "***"); //"my login name is my email itself, and password.
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = info;
//From address will be given as a MailAddress Object
message.From = fromAddress;
// To address collection of MailAddress
message.Subject = "Test-Subject";
//Body can be Html or text format
//Specify true if it is html message
message.IsBodyHtml = false;
// Message body content
message.Body = "Test Body";
// Send SMTP mail
smtpClient.Send(message);
Response.Write("Mail sent successfully :-)");
}
catch (Exception ex)
{
Response.Write("Oops! Error encountered. " + ex.Message.ToString());
}
}
}
-
Mar 15th, 2008, 10:40 PM
#7
Hyperactive Member
Re: [2005] Email
Yes that code was straight off the top of my head i am still looking for my e-mail application that worked.
-
Mar 16th, 2008, 08:32 AM
#8
Thread Starter
Frenzied Member
Re: [2005] Email
ok so now i need to convert it....just wondering can VB 2005 use tags? to insert another code into a visual basic code? Ive never done that before since i only know visual basic.
-
Mar 16th, 2008, 08:37 AM
#9
Re: [2005] Email
there are loads of websites that do vb to c# .net conversion and vice versa.
Just copy/paste that code in and it will change it for you.
Code converter
-
Mar 16th, 2008, 01:00 PM
#10
Re: [2005] Email
noahssite, ASP.NET questions - ASP.NET Forum. You'll have a better chance of getting asp.net related answers there.
-
Mar 16th, 2008, 01:51 PM
#11
Thread Starter
Frenzied Member
Re: [2005] Email
Only have of it got converted there was an error with the code converter site
-
Mar 16th, 2008, 02:27 PM
#12
Re: [2005] Email
There's really not much difference in the code compared to the vb version
Instead of 'Using' it's 'Imports' in VB
Variable delcarations are simply changed from:
vb Code:
SmtpClient smtpClient = new SmtpClient(); MailMessage message = new MailMessage();
to:
vb Code:
Dim smtpClient As New smtpClient Dim message As New MailMessage
Just do the same thing for the other variable declarations and take the ; character off the end of the other lines and that's it really. A little effort working it out will have it done in minutes.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|