|
-
Feb 26th, 2008, 01:07 AM
#1
Thread Starter
Lively Member
[2008] Send an email
How do i send an email which extracts the email address from a textbox and sends the login details from the database.
-
Feb 26th, 2008, 01:17 AM
#2
Re: [2008] Send an email
This is a common question and, as such, has been answered many times. Raed the MSDN documentation for the System.Net.Mail.MailMessage class for a code example or search the forum. The values that you assign to the properties of the MailMessage, like To and Body, can come from wherever you like.
-
Feb 29th, 2008, 07:11 AM
#3
Thread Starter
Lively Member
Re: [2008] Send an email
I couldnt find the documentation you mentioned. could you please direct me to the site.
-
Feb 29th, 2008, 07:16 AM
#4
Fanatic Member
-
Feb 29th, 2008, 07:30 AM
#5
Re: [2008] Send an email
What is up with all these people who "can't find" a Help menu? Open Visual Studio, select Help -> Index from the main menu and type mailmessage into the box. It's not rocket science. It's not even programming. It's just using a computer.
-
Mar 1st, 2008, 12:15 AM
#6
Thread Starter
Lively Member
Re: [2008] Send an email
sorry but im new to programming. I just cant figure out how to send the email in VB.net
-
Mar 1st, 2008, 06:49 PM
#7
Re: [2008] Send an email
Being new to programming is no reason to not be able to find a topic in a Help file. Any computer user should be able to do that. That said, the MailMessage documentation has code examples in C#, C++ and J# but no VB. Here's the output from Instant VB when converting the C# example:
vb.net Code:
Public Shared Sub CreateMessageWithAttachment(ByVal server As String) ' Specify the file to be attached and sent. ' This example assumes that a file named Data.xls exists in the ' current working directory. Dim file As String = "data.xls" ' Create a message and set up the recipients. ' Create the file attachment for this e-mail message. Dim data As Attachment = New Attachment(file, MediaTypeNames.Application.Octet) ' Add time stamp information for the file. Dim disposition As ContentDisposition = data.ContentDisposition disposition.CreationDate = System.IO.File.GetCreationTime(file) disposition.ModificationDate = System.IO.File.GetLastWriteTime(file) disposition.ReadDate = System.IO.File.GetLastAccessTime(file) ' Add the file attachment to this e-mail message. message.Attachments.Add(data) 'Send the message. Dim client As SmtpClient = New SmtpClient(server) ' Add credentials if the SMTP server requires them. client.Credentials = CredentialCache.DefaultNetworkCredentials client.Send(message) ' Display the values in the ContentDisposition for the attachment. Dim cd As ContentDisposition = data.ContentDisposition Console.WriteLine("Content disposition") Console.WriteLine(cd.ToString()) Console.WriteLine("File {0}", cd.FileName) Console.WriteLine("Size {0}", cd.Size) Console.WriteLine("Creation {0}", cd.CreationDate) Console.WriteLine("Modification {0}", cd.ModificationDate) Console.WriteLine("Read {0}", cd.ReadDate) Console.WriteLine("Inline {0}", cd.Inline) Console.WriteLine("Parameters: {0}", cd.Parameters.Count) For Each d As DictionaryEntry In cd.Parameters Console.WriteLine("{0} = {1}", d.Key, d.Value) Next d data.Dispose() End Sub
Even with that code, you should still READ the entire Help topic and also follow any relevant links, including those to the members for the MailMessage class and also the related class used in that code, like Attachment and SmtpClient.
-
Mar 15th, 2008, 01:33 PM
#8
Frenzied Member
-
Mar 15th, 2008, 01:34 PM
#9
Frenzied Member
Re: [2008] Send an email
nvm srry i didnt really see
-
Mar 31st, 2008, 03:17 AM
#10
Thread Starter
Lively Member
Re: [2008] Send an email
Should this code be used in the button click event??
-
Mar 31st, 2008, 07:40 AM
#11
Re: [2008] Send an email
 Originally Posted by Colin Dias
Should this code be used in the button click event??
You tell me. Do you want to send a message when a Button is clicked? If you do then you'd put the code in the Button's Click event handler. If you don't then you wouldn't.
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
|