private void GenerateLetter(Word.Selection wrdSelection, Word.MailMerge wrdMailMerge, out Word.MailMergeFields wrdMergeFields) { // Create a string and insert it into the document. wrdSelection.Font.Bold = 1; var strToAdd = _mailMergeData.Originator.Company + Environment.NewLine + _mailMergeData.Originator.Department; wrdSelection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter; wrdSelection.ParagraphFormat.LineSpacingRule = Word.WdLineSpacing.wdLineSpaceSingle; wrdSelection.TypeText(strToAdd); InsertLines(4); // Insert merge data. wrdSelection.Font.Bold = 0; wrdSelection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft; wrdMergeFields = wrdMailMerge.Fields; wrdMergeFields.Add(wrdSelection.Range, "Name"); wrdSelection.TypeParagraph(); wrdMergeFields.Add(wrdSelection.Range, "Address"); InsertLines(2); // Right justify the line and insert a date field // with the current date. wrdSelection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight; Object objDate = "dddd, MMMM dd, yyyy"; wrdSelection.InsertDateTime(ref objDate, ref _oFalse, ref _oMissing, ref _oMissing, ref _oMissing); InsertLines(2); // Justify the rest of the document. wrdSelection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphJustify; wrdSelection.TypeText("Dear "); wrdMergeFields.Add(wrdSelection.Range, "Name"); wrdSelection.TypeText(","); InsertLines(2); //insert the messagebody wrdSelection.TypeText(_mailMergeData.MessageBody); InsertLines(2); // Go to the end of the document. Object oConst1 = Word.WdGoToItem.wdGoToLine; Object oConst2 = Word.WdGoToDirection.wdGoToLast; _wrdApp.Selection.GoTo(ref oConst1, ref oConst2, ref _oMissing, ref _oMissing); InsertLines(2); strToAdd = "Thank You," + Environment.NewLine + _mailMergeData.Originator.Name + Environment.NewLine + _mailMergeData.Originator.Designation; wrdSelection.TypeText(strToAdd); }