2
Answers

Word Templates updating from SQL Server dtabase

Balaji Yerukola

Balaji Yerukola

13y
3.1k
1
Hi All,

Currently I have a requirement which is follows:

I have a word template which contains some text information and with some fields like "ADDRESS" and "DATE" "NAME" in the word templates.

I have developed a Windows forms application with C#.Net and SQL Server Database. The windows forms application contains the navigation buttons like "FIRST","NEXT","LAST","PREVIOUS". and a button called PRINT as well as some text boxes to show the records in the database while navigating.

Whenever user clicks PRINT button it have to take a word template from a shred folder and it will update all the above said fields which are available in the WORD document with the current record details. This is some thing like MAIL MERGE activity.

Please help me to resolve the issue. And also please possible solutions in order to fulfill my requirement.

Thanks in Advance
Balaji Yerukola


Answers (2)
0
Kirtan Patel

Kirtan Patel

NA 35k 2.8m 15y
Why don't you use Gmail Server . its working well ..

Yahoo Server Does not Provide..SMTP Service for Free

follow this great article ..you will have idea about sending mail with attachment .

http://www.c-sharpcorner.com/UploadFile/meetuchoudhary/sendmail08142009123125PM/sendmail.aspx

code is for asp.net but its working under Windows Form application too...

if my answer helped you then check "Do you like this answer" check box


Accepted
0
hanafi tanudjaja

hanafi tanudjaja

NA 41 0 15y
hello home base


thank you

it work

regard
han
0
Lalit M

Lalit M

NA 6.7k 48k 15y
You can also try this code sample


MailMessage Mail = new MailMessage();

MailAddress ma = new MailAddress(txtFrom.Text,txtName.Text);
Mail.From = ma;
Mail.To.Add(txtTo.Text);

if(txtCC.Text.Trim().Length != 0)
Mail.CC.Add(txtCC.Text);

if(txtBCC.Text.Trim().Length != 0)
Mail.Bcc.Add(txtBCC.Text);

Mail.Subject = txtSubject.Text;


if (txtAttachment.Text.Trim().Length != 0)
{
string sAttach = txtAttachment.Text.Replace("\\","\\\\");
Mail.Attachments.Add(new Attachment(sAttach));
}


//Note: When you make "
IsBodyHtml" to true make
//ValidateRequest="
false" in page derective
//As to make HTML content passed.
Mail.IsBodyHtml = true;
Mail.Body = txtComment.Text;


//Setting Reply address.
if (txtReplyTo.Text.Trim().Length != 0)
{
Mail.Headers.Add("
Reply-To", txtReplyTo.Text);
}
else
{
Mail.Headers.Add("
Reply-To", txtFrom.Text);
}


try
{
SmtpClient smtpMailObj = new SmtpClient();
//eg:localhost, 192.168.0.x, replace with your server name
smtpMailObj.Host = "
myMailServer";
smtpMailObj.Send(Mail);
Response.Write("
Your Message has been sent successfully");
}
catch (Exception ex)
{
Response.Write("
Message Delivery Fails");
}

reference link

more info

hope you will get your answer,Thanks ....