My EShip came with a MAILOCX - lets try it!

SavatageSavatage Member Posts: 7,142
edited 2012-12-19 in NAV Tips & Tricks
Our EShip came with an email OCX. It can be used in the system to send mails if you don't want to use CU397 (for whatever reason)

the useable fields:
MailOCX.LineFeedChar := '';
MailOCX.InitializeMail('Your Email Subject');
MailOCX.AddReceiverTo('youremail1-at-yourdomain.net');
MailOCX.AddReceiverCC('youremail2-at-yourdomain.net');
MailOCX.AddReceiverBCC('youremail3-at-yourdomain.net');
MailOCX.AddtoBody(FieldValue.SubstituteLine(EMailBodyLine));
MailOCX.AddAttachment(TempFilename);
MailOCX.Send(FALSE); //false = send automatically
For example I tried it on a button on the item card that quickly creates an email of the item details and attaches a picture.

OnPush()
User.GET(USERID);
CALCFIELDS(Picture);
IF Picture.HASVALUE THEN BEGIN
 EmailSubject := 'Please Update: Item '+"No."+' Picture Attached';
 EmailBody := 'Item '+"No."+' Picture Attached';
 TempFileName := 'P:\jpg\'+"No."+'.jpg';
MailOCX.LineFeedChar := '';
MailOCX.InitializeMail(EmailSubject);
MailOCX.AddReceiverTo(User."User Email Address");
MailOCX.AddtoBody('Item#: '+"No."+'\'); //note baskslash forces new line in body
MailOCX.AddtoBody(Description+' '+"Description 2"+'\');
MailOCX.AddtoBody('UPC: '+"Item UPC/EAN Number"); 
MailOCX.AddAttachment(TempFileName);
MailOCX.Send(TRUE); //creates email but doesn't send until user sends
END;

On Table 112 - to tell me who's trying to delete records!!
OnDelete()
SendMail;

SendMail()
User.GET(USERID);
MailOCX.LineFeedChar := '';
MailOCX.InitializeMail('Sales Invoice Deletion Attempt');
MailOCX.AddReceiverTo('youremail1-at-yourdomain.net');
MailOCX.AddReceiverCC('youremail2-at-yourdomain.net');
MailText := 'Date:'+FORMAT(TODAY)+' '+'Time:'+FORMAT(TIME)+' '+'User:'+FORMAT(User."User ID")+' '+'Invoice#:'+FORMAT("No.");
MailOCX.AddtoBody(MailText);
MailOCX.Send(FALSE);
CLEAR(MailOCX);

Just an FYI probably nobody else needs this 8)
Sign In or Register to comment.