Hello,
Issue is that in the following codeunit when creating subsequent notes only the 1st one successfully sends "Note" content.
This isn't an issue in NAV 2017 for some reason, but is a problem in NAV 2013 r2.
I Checked in Debugger, on first iteration NoteText = "test1",
On second iteration NoteText is empty.
what could be the reason? thank you. ;(
SalesSetup.GET();
CompInfo.GET();
PastTime := CURRENTDATETIME - (5 * 60 * 60 * 1000);
RecordLink.RESET();
RecordLink.SETRANGE(Created, PastTime, CURRENTDATETIME);
IF RecordLink.FINDFIRST() THEN BEGIN
REPEAT
UserSetup.RESET();
UserSetup.SETRANGE("User ID", RecordLink."To User ID");
UserSetup.SETFILTER("E-Mail", '<>%1', '');
RecordLink.SETFILTER(Notify, '<>%1', FALSE);
CLEAR(NoteStream);
CLEAR(NoteText);
RecordLink.CALCFIELDS(Note);
RecordLink.Note.CREATEINSTREAM(NoteStream, TEXTENCODING::UTF8);
NoteStream.READTEXT(NoteText);
CLEAR(NoteStream);
EmailMessage := DELSTR(NoteText, 1, 1);
IF UserSetup.FINDFIRST() THEN BEGIN
SMTP.CreateMessage(
CompInfo.Name,
SalesSetup."Send From E-mail",
UserSetup."E-Mail",
'Nuo: ' + RecordLink."User ID" + ' | ' + RecordLink.Description,
EmailMessage,
TRUE);
SMTP.TrySend;
END;
UNTIL RecordLink.NEXT() = 0;
END;
0
Answers
I guess it mostly depends on how you wrote the text to the note in the first place.
NAV 2013 R2 has code for this in Codeunit 454 Job Queue - Send Notification
I would assume this creates a Note BLOB content equal to what you would get by editing in the System Part with SystemPartID = Notes.
I would assume that this code should produce the same result as And therefore I would assume that your code would read the content correctly except for the following two potential problems:
Furthermore I do not know what SMTP.CreateMessage supports in your version. The problem might be there entirely, and not at all in reading the Note content. Mail creation has always been a source of trouble as soon as you used any non-ASCII characters.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!