Email with Mail Merge functionality

snehalppatel
Member Posts: 34
Hello All,
I know of mail merge using Word document to send it as an attachment to multiple recipients, using interaction Template in NAV. But, my client wants to use either SMTP or Outlook to send an email to multiple recipients. He wants to add multiple Contacts from NAV Contacts and send them an email with fields like mail merge, that might contain the recipient's name, address etc. The condition is the mail should be a plain or HTML mail, and it should not go as attachment like Word document mail merge, instead it should go as a simple email. Is there any provision in NAV to do something similar, or is anyone known to a component which can provide this functionality and is compatible with NAV.
Various solutions or work arounds are welcome.
Thanks in advance,
I know of mail merge using Word document to send it as an attachment to multiple recipients, using interaction Template in NAV. But, my client wants to use either SMTP or Outlook to send an email to multiple recipients. He wants to add multiple Contacts from NAV Contacts and send them an email with fields like mail merge, that might contain the recipient's name, address etc. The condition is the mail should be a plain or HTML mail, and it should not go as attachment like Word document mail merge, instead it should go as a simple email. Is there any provision in NAV to do something similar, or is anyone known to a component which can provide this functionality and is compatible with NAV.
Various solutions or work arounds are welcome.
Thanks in advance,
Snehal Kumar Patel
MCTS - Microsoft Dynamics NAV
MCTS - Microsoft Dynamics NAV
0
Comments
-
Never done this exact thing before, but here's an idea.
-
Do the standard mail merge with a word document
Save the resulting file as an HTML file instead of a word document
Open the HTML file and use the text as the body of the email using the Mail codeunit.
That could work..not sure about the effort level or if something better / easier exists.0 -
There are a number of SMTP solutions that can easily be integrated into Navision. I haven't used Jmail, but it's listed in the downloads section here on MIBUSO:
http://www.mibuso.com/dlinfo.asp?FileID=1156
I've used ANSMTP, which is a commercial product, very good support, moderately priced, available at http://www.emailarchitect.net.
The technique I've used for mailmerge is to create a table with a column for boilerplate text of your email, plus some columns that contain the names of substitution fields. Then, the message can be "merged" with the STRSUBSTNO command before it is output to the SMTP function.
The way I've done it is to use the FIELD table and a FieldRef type variable to reference the values in a record.
Here is a VERY crude example. It assumes you have a message template table with the following fields:
SubstFieldName1
SubstFieldName2
SubstFieldName3
BodyTemplate
The first three fields contain the fieldnames that you want to insert into the BodyTemplate message. So in the code below, we're inserting Vendor fields (record variable VendRec): VendRec.Name, VendRec.Address and VendRec."Address 2":
BodyTemplate := 'This is the body of the message with the Vendor name here %1 then address %2 then address 2 %3';
SubstFieldName1 := 'Name';
SubstFieldName2 := 'Address';
SubstFieldName3 := 'Address 2';
VendRec.FINDFIRST;
RecRef.GETTABLE(VendRec);
Fld.SETRANGE(TableNo, DATABASE::Vendor);
Fld.SETRANGE(FieldName, SubstFieldName1);
Fld.FINDFIRST;
FldRef[1] := RecRef.FIELD(Fld."No.");
Fld.SETRANGE(FieldName, SubstFieldName2);
Fld.FINDFIRST;
FldRef[2] := RecRef.FIELD(Fld."No.");
Fld.SETRANGE(FieldName, SubstFieldName3);
Fld.FINDFIRST;
FldRef[3] := RecRef.FIELD(Fld."No.");
MessageBody := STRSUBSTNO(SubText,FORMAT(FldRef[1].VALUE), FORMAT(FldRef[2].VALUE), FORMAT(FldRef[3].VALUE) );
Assuming the Vendor's name and address are:
Global Manufacturing
123 Anywhere Street
Suite A
After the code above, the variable "MessageBody" will look like:
This is the body of the message with the Vendor name here Global Manufacturing then address 123 Anywhere Street then address 2 Suite A
I know the code is crude but it illustrates the use of STRSUBSTNO and use of FieldRef's to get values of fields into a string.
If you have only one email message you don't have to use a table - you can just create the text in-line with your code. But I favor building the table so that when (not if) a second email has to be composed, you have the structure for it all done.
Hope this helps.Ron0 -
Thanks to mattrax & rsaritzky both. I will try implementing your solutions, and will get back soon.
Thanks once again.Snehal Kumar Patel
MCTS - Microsoft Dynamics NAV0 -
Hi all guys, have a question for you:
I use a customized mailmerge to send email to customer. There's a way to change the sender mail adress?
Thank you in advice and excuse my english.
Piercarlo0 -
pierca wrote:Hi all guys, have a question for you:
I use a customized mailmerge to send email to customer. There's a way to change the sender mail adress?
Thank you in advice and excuse my english.
Piercarlo
You should be able to change the sender email address. It depends how your customized mailmerge is built. But the code that specifies the email address would be able to be changed, depending on how you wanted it to work. If you can provide more details how it works, then maybe we can help you.Ron0 -
Codeunit 400 lets you change it.
If you use the older codeunit 397, you cannot do it thru code.David Machanick
http://mibuso.com/blogs/davidmachanick/0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions