0

So I'am trying to send an Email(with links in it) via Lotus Notes.

But it seems that Lotus has some Problems with URL's where a questionmark ("?") is inside of the URL.

This is my Code.

var emailContentStringBuilder = new StringBuilder();
foreach (var document in entities)
{
    emailContentStringBuilder.AppendLine("\n" + document.FileName);
    emailContentStringBuilder.AppendLine( _customerConfiguration.GetAttachmentUrl(document.EntityName));
    emailContentStringBuilder.AppendLine();
}

var emailBody = String.Format(EpmResources.DocumentsEmailBodyFormat, emailContentStringBuilder);
emailBody = emailBody.Replace("\n", "%0D%0A");

Device.OpenUri(new Uri(String.Format("mailto:?&subject={1}&body={0}", emailBody, EpmResources.DocumentsEmailSubject)));

When i use this code and try to open Lotus via my Application the Emailbody and subject are empty.

I switched then Subject and Emaildbody in code.

Device.OpenUri(new Uri(String.Format("mailto:?&body={0}subject={1}", emailBody, EpmResources.DocumentsEmailSubject)));

That somehow worked a bit but it showed the subject and only a part of the emaildbody. I then look where the Emailbody stoped via debugging and noticed that it was before an "?" where it stoped showing.

so i tried replacing the "?" in the Emailbody and that worked fine.

emailBody = emailBody.Replace("?", " ");

but the Problem is i need those questionmarkes as they are a Part of an URL. Under Outlook this code works fine. So is this a lotus thing? Hopefully someone can explain this to me.

Igor
  • 60,821
  • 10
  • 100
  • 175
nani
  • 183
  • 2
  • 15
  • 1
    Most likely you need to Uri encode the whole body string if you want it to be a part of a `mailto:` uri. Same goes for subject if this is variable. – Igor Oct 16 '18 at 12:32
  • 1
    Comment me back if the following duplicate does not address the issue (it should though). – Igor Oct 16 '18 at 12:34
  • Thanks a lot. That helped. var emailBodyEncode = Uri.EscapeDataString(emailBody); and then Device.OpenUri(new Uri(String.Format("mailto:?&subject={1}&body={0}", emailBodyEncode, EpmResources.DocumentsEmailSubject))); – nani Oct 16 '18 at 12:44

0 Answers0