换行符不会出现在Notes的邮件正文中

Anu*_*nuj 1 c# email lotus-notes lotus-domino

我是Notes的新手.我正在尝试使用带有附件的Lotus Notes从我的应用程序发送邮件,邮件正常,附件也可以,但问题是身体内容,身体失去其格式并且直线

我希望如下

Dear Sir,
please check the attachment.


Regards,
NewConcept Infotech Pvt.Ltd.,
Run Code Online (Sandbox Code Playgroud)

但它是这样的

Dear Sir,please check the attachment.Regards,NewConcept Infotech Pvt.Ltd.,
Run Code Online (Sandbox Code Playgroud)

我尝试了一切google搜索但没有用.

这是我的代码

 public bool Email(string dbDirectory, string DataBase_Name, string Initialize_Pwd, string From, string To, string CC, string Bcc, string Subject, string body, string FileName, string LogFilePath)
        {
            bool msg = false;
            dynamic EMailReplyTo = ConfigurationSettings.AppSettings["EMailReplyTo"];
            NotesSession objNotesSession = new NotesSession();
            NotesDatabase ndb = null;
            NotesDocument ndoc = null;
            NotesDbDirectory ndbD = null;
            NotesStream LNStream;
            NotesMIMEEntity LNBody;
            object objAttach;
            try
            {
                ////--------------------Lotus Notes Connectivity-------------------------///
                List<string> lstOutPutEmail = new List<string>();
                lstOutPutEmail.Add(DataBase_Name);
                lstOutPutEmail.Add(Initialize_Pwd);

                objNotesSession.Initialize(lstOutPutEmail[1].ToString());
                ////  objNotesSession object Initialized

                ndbD = objNotesSession.GetDbDirectory(dbDirectory);

                ndb = objNotesSession.GetDatabase(dbDirectory, DataBase_Name, false);

                //If the database is not already open then open it.
                if (!ndb.IsOpen)
                {
                    ndb.Open();
                }

                if (ndb != null)
                {
                    ndoc = ndb.CreateDocument();
                    LNStream = objNotesSession.CreateStream();
                    LNBody = ndoc.CreateMIMEEntity();
                    //   ndoc.ReplaceItemValue("SendBy", From);
                    ndoc.ReplaceItemValue("Form", "Memo");
                    ndoc.ReplaceItemValue("From", From);
                    ndoc.ReplaceItemValue("Principal", From);
                    ndoc.ReplaceItemValue("SendTo", To.Split(','));
                    if (CC != null)
                    {
                        if (CC != "")
                        {
                            ndoc.ReplaceItemValue("CopyTo", CC.Split(','));
                        }
                    }
                    if (Bcc != null)
                    {
                        if (Bcc != "")
                        {
                            ndoc.ReplaceItemValue("BlindCopyTo", Bcc.Split(','));
                        }
                    }
                    ndoc.ReplaceItemValue("Subject", Subject);
                    //

                    NotesRichTextItem objMailRTF = ndoc.CreateRichTextItem("Body");



                    ndoc.ReplaceItemValue("Body", body);



                    ndoc.SaveMessageOnSend = true;
                    if (FileName != "")
                    {
                        objAttach = objMailRTF.EmbedObject(Domino.EMBED_TYPE.EMBED_ATTACHMENT, "", FileName, "Attachment");
                    }
                    ndoc.Send(false);
                    ndbD = null;
                    objNotesSession = null;
                    ndb = null;
                    ndoc = null;
                    gl.runLogfile("Mail Send Successfuly To : " + To, LogFilePath);
                }
                msg = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error On sending Mail To : " + To);
                gl.runLogfile("Error On sending Mail To : " + To, LogFilePath);
                gl.runLogfile(ex.Message, LogFilePath);
                msg = false;
            }
            finally
            {

            }
            return msg;
        }
Run Code Online (Sandbox Code Playgroud)

Knu*_*ann 5

使用RichTextItem的方法AddNewLine()会在Body字段中添加新行

NotesRichTextItem objMailRTF = ndoc.CreateRichTextItem("Body");
objMailRTF.AppendText("Dear Sir,");
objMailRTF.AddNewLine(1);
objMailRTF.AppendText("please check the attachment.");
objMailRTF.AddNewLine(2);
...
Run Code Online (Sandbox Code Playgroud)

删除代码行ndoc.ReplaceItemValue("Body", body);,否则将无法使用.