3,977 questions
Hi there!
The extra newline character is likely a result of the way the text data is formatted or retrieved from MS Graph API.
We can use following C++ code by processing the mail body string response as mentioned below:
std::string mailBody = "This is a sample mail body.\n\n\n\nSample New lines.\n\n\n\n";
std:: regex regexNewlines("(\\r\\n|\\n){2,}");
mailBody = std::regex_replace(mailBody, regexNewlines, "\n");
std::cout << mailBody << std::endl;
```Below is a JavaScript code snippet (web context) for processing the mail body string:
```javascript
let mailBody = "This is a sample mail body.\n\n\n\nSample New lines.\n\n\n\n";
const regexNewlines = /(\r\n|\n){2,}/g;
mailBody = mailBody.replace(regexNewlines, "\n");
console.log(mailBody);
We suggest processing the response received in MS Graph API.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".