actually i have used mail on vb.net windows forms
i have used this code for this -
Imports System.Net.Mail
-
-
'Inside the form’s code window:
-
-
Public Sub SendAnEmail(ByVal MsgFrom As String, ByVal MsgTo As String, ByVal MsgSubject As String, ByVal MsgBody As String)
-
-
Try
-
-
' Pass in the message information to a new MailMessage
-
-
Dim msg As New Net.Mail.MailMessage(MsgFrom, MsgTo, MsgSubject, MsgBody)
-
-
-
-
' Create an SmtpClient to send the e-mail
-
-
Dim mailClient As New SmtpClient("127.0.0.1") ' = local machine IP Address
-
-
' Use the Windows credentials of the current User
-
-
mailClient.UseDefaultCredentials = True
-
-
-
-
' Pass the message to the mail server
-
-
mailClient.Send(msg)
-
-
' Optional user reassurance:
-
-
MessageBox.Show(String.Format("Message Subject ' {0} ' successfully sent From {1} To {2}", MsgSubject, MsgFrom, MsgTo), "EMail", Windows.Forms.MessageBoxButtons.OK, Windows.Forms.MessageBoxIcon.Information)
-
-
' Housekeeping
-
-
msg.Dispose()
-
-
Catch ex As FormatException
-
-
MessageBox.Show(ex.Message & " :Format Exception")
-
-
Catch ex As SmtpException
-
-
MessageBox.Show(ex.Message & " :SMTP Exception")
-
-
End Try
-
End Sub
Then all that remains to do is create some calling code . This example uses a button click to send data that I type into four textboxes with self-explanatory names: (You can replace them with literal strings of your own) -
-
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
-
-
SendAnEmail(FromBox.Text, ToBox.Text, SubjectBox.Text, MsgBodyBox.Text)
-
-
End Sub
but it gives the error unable to find server 5.7.1 and mail sending is failed i
i have already configure iis and settings also smtp mail server but it can't work
when i have used on web application then it fine work so if you have any solution regarding this then plz help me
thanks in advance
1 2583
using System.Web.Mail ;
MailMessage mailobj = new MailMessage();
mailobj.To = "a@a.com";
mailobj.From = "x@x.com";
mailobj.Subject = "Hi this is the test mail";
mailobj.BodyFor mat = MailFormat.Html ;
string strBody = "hi this is the test mail;
mailobj.Body = strBody;
SmtpMail.Send(m ailobj);
use the above code to send mail in C#.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Bruce W...1 |
last post by:
In my effort to learn PHP I'm playing with some simple email scripts. They
worked a few days ago but they stopped working. The only thing I've done to
this Windows 2000 PC in this time was a Windows Update which I do regularly.
The only part of this update that might be related was an IE 6 update.
So I uninstalled and reinstaled PHP 4.3.3. The mail server setting is correct
in the php.ini file. But email is still not being sent.
...
|
by: Jim Seymour |
last post by:
I have a contact form that uses PHP's mail() function. It recently
came to my attention that (some?) MS-Windows mail servers may not
properly process data given to the mail() function that's only
newline-terminated.
The mail() function takes up to five parameters:
mail(recipient, subject, message, ])
The ones of interest here are the first four. The questions are
|
by: baustin75 |
last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie
only when debugging in php designer 2005
--------------------------------------------------------------------------------
Hello,
I have a very simple problem but cannot seem to figure it out. I have a
very simple php script that sends a test email to myself. When I debug
it in PHP designer, it works with no problems, I get the test email. If
|
by: ElanKathir |
last post by:
Hi !
I wrote one code for Send the E-mail, But that code have some problem , So please help me
Here i paste my code and Error:
Error:
Server Error in '/Elan_Sample' Application.
--------------------------------------------------------------------------------
|
by: Rene |
last post by:
Hi all
i need some help. i try to send mail with the following code.
Private Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
Dim mailMsg As New MailMessage
mailMsg.From = rene.fehr@netradox.com
mailMsg.To = info@netradox.com
mailMsg.Subject = "Testmail vom Webforum"
mailMsg.Body = "some body text"
| |
by: Tim |
last post by:
I am trying to send a simple mail message using windows forms in VB.NET 2005.
When executing the code, I get a general 'Configuration system failed to
initialize' error message when the code instatiates a new MailMessage object
(see below) My form has the following code:
Imports System.Net.Mail
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
|
by: Robert Dufour |
last post by:
I am trying to use framework 1.1 - stuck with it. to send emails from a
windows form application. The email messages can have attachments, usually
two and they can be either text or sounds (wav files) or images (bmp, gif or
tiff)
I can send the email messages OK but the attachments are giving me grief.
Can anyone provide some code that adds attachments to web mail messages.
Thanks for any help,
|
by: mr k |
last post by:
Hi,
I wanted to use mail merge with forms but Text form fields are not retained during mail merge in Word, I got the code from Microsoft but it doesn't remember the text form field options such as the maximum length of the text (which I need) and the text format (would be ideal but can do without if need be)
I have posted the code below, so please can you help!?? Thanks in advance...
Sub PreserveMailMergeFormFieldsNewDoc()
Dim...
|
by: shror |
last post by:
hi every body,
i have a problem which is when i was checking my mail() form it work
fine but the problem is that the form configuration is not set
correctly, in details:
the from var is not working and the from is set to be my host provider
email is the sender, so they told me to configure the php.ini file and
i dont know what is this file and how to configure it.
thanks in advance
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |