TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Abhimanyu Singh
NA
116
48.9k
how to send the pasted text in mail without database interac
Dec 4 2012 2:29 AM
how to send the pasted text in mail without database interaction.
I have putted the following code it is sending the mail with attachment but
is not taking pasted text from text boxes(but it is taking written text in that textbox).
any body can help me Please:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Net;
using System.Net.Mail;
using System.Web.Mail;
public partial class career : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
if (FileUpload1.PostedFile.ContentLength < 2097152) //actually it takes file size in byte so 2MB=2097152byte(1024*1024*2) and also put it in web configuration page under <System.Web>
{
try
{
string s = FileUpload1.PostedFile.ContentLength + FileUpload1.FileName;
FileUpload1.SaveAs(Server.MapPath("~\\") + "images\\" + "upload_resume\\" + s);
Label1.Text = Server.MapPath("~\\") + "images\\" + "upload_resume\\" + s;
//mail for Company owner(eventale)
System.Web.Mail.MailMessage objMM1 = new System.Web.Mail.MailMessage();
//Dim Attachment As System.Web.Mail.MailAttachment
objMM1.To = "
[email protected]
";
objMM1.From = "
[email protected]
";
objMM1.BodyFormat = System.Web.Mail.MailFormat.Text;
objMM1.Priority = System.Web.Mail.MailPriority.High;
objMM1.Subject = "We have received the Details from career's Applicant.";
objMM1.Body = "Dear Sir/Madam,\r\n\r\n" +
"The followings are the details of Applicant: \r\n\r\n" +
"Name: " + TextBox1.Text + "\r\n" +
"Marital Status: " + DropDownList1.SelectedItem.Value + "\r\n" +
"Gender: " + DropDownList2.SelectedItem.Value + "\r\n" +
"Date of Birth: " + TextBox2.Text + "\r\n" +
"Email: " + TextBox3.Text + "\r\n" +
"Phone: " + TextBox4.Text + "\r\n" +
"Current Location: " + TextBox5.Text + "\r\n" +
"Current Employer " + TextBox6.Text + "\r\n" +
"Total Experience: " + TextBox7.Text + "\r\n" +
"Position Applying for: " + TextBox8.Text + "\r\n" +
"Or Paste Resume here: " + TextBox9.Text + "\r\n";
//"Hoarding Id: " + Session["a"].ToString() + "\r\n";
string filepath = Server.MapPath("images\\" + "upload_resume\\" + s);
//Response.Write(filepath);
objMM1.Attachments.Add(new System.Web.Mail.MailAttachment(filepath));
//Attachment attached = new Attachment(Label1.Text);
//objMM1.Attachments.Add(attached);
//string fileAttach = Server.MapPath("~\\") + "images\\" + "upload_resume\\" + s;
//Attachment attach = new Attachment(fileAttach);
objMM1.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserver"] = "smtp.gmail.com";
objMM1.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserverport"] = 465;
objMM1.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing"] = 2;
objMM1.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1;
objMM1.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] = "eventale2012";
objMM1.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = "eventale@2012";
objMM1.Fields["http://schemas.microsoft.com/cdo/configuration/smtpusessl"] = true;
System.Web.Mail.SmtpMail.SmtpServer = "smtp.gmail.com";
//smtpmail.SmtpServer.ite
//Now, to send the message, use the Send method of the SmtpMail class
System.Web.Mail.SmtpMail.Send(objMM1);
Label1.Visible = false;
}
catch (Exception ex)
{
//Response.Write("<script>alert('Currently there is some error, Try again after some time.')</script>");
Response.Write("Error: " + ex.Message);
}
}
else
{
Response.Write("<script>alert('File size exceeds maximum limit 2 MB')</script>");
}
Page.ClientScript.RegisterStartupScript(this.GetType(), "test", "alert('Submitted successfully');", true); // for getting alert/pop msg without any scattered data in page.
TextBox1.Text = " "; // For refreshing the page
TextBox2.Text = " ";
TextBox3.Text = " ";
TextBox4.Text = " ";
TextBox5.Text = " ";
TextBox6.Text = " ";
TextBox7.Text = " ";
TextBox8.Text = " ";
TextBox9.Text = " ";
}
}
}
Reply
Answers (
0
)
RSS reader
Using Grid view how to check Vendor name already exists