Multiple attachments via codeunit 397 (mail) : again...

BGI
Member Posts: 176
I have seen a lot of solutions to the problem of putting multiple attachments in a mail message created via codeunit 397.
But or i'm not looking correctly, but i didn't found any:using the 397 codeunit version 3.70,4.00.. (the one with automation.) and putting multiple attachments on it.
Why i'm looking for it?
To finaly have a codeunit where you can:
- use multiple, nice formated body lines (with the function addbodyline)
- use multiple recipients ..
and use multiple attachments...
But or i'm not looking correctly, but i didn't found any:using the 397 codeunit version 3.70,4.00.. (the one with automation.) and putting multiple attachments on it.
Why i'm looking for it?
To finaly have a codeunit where you can:
- use multiple, nice formated body lines (with the function addbodyline)
- use multiple recipients ..
and use multiple attachments...
Rgds
Benny Giebens
Benny Giebens
0
Comments
-
you can repeat this code for mutiple attachements:
IF AttachFileName <> '' THEN BEGIN
BSTRConverterAttachFileName.ResetBSTR;
BSTRConverterAttachFileName.AppendNextStringPortion(AttachFileName);
OAttachments := OSendMail.Attachments;
OAttachment := OAttachments.Add(BSTRConverterAttachFileName);
END;0 -
Hy,
if checked the functionality with up to 100 attachments.
The solution of the problem is very simple, if you know how.
1) Create a new Function in codeunit 397 identical to the function NewMessage, let's call it "NewMessageMultipleAttachments".
2) Replace the field "AttachFileName" by an array called e.g. "AttachFileNames".
3) Assign number of dimensions you need.
(The calling function must fit with the number of dimensions used here)
4) Modify the partIF AttachFileName <> '' THEN BEGIN BSTRConverterAttachFileName.ResetBSTR; BSTRConverterAttachFileName.AppendNextStringPortion(AttachFileName); OAttachments := OSendMail.Attachments; OAttachment := OAttachments.Add(BSTRConverterAttachFileName); END;
like thisFOR FileNameCounter:= 1 TO ARRAYLEN(AttachFileNames) DO BEGIN IF AttachFileNames[FileNameCounter] <> '' THEN BEGIN BSTRConverterAttachFileName.ResetBSTR; BSTRConverterAttachFileName.AppendNextStringPortion(AttachFileNames[FileNameCounter]); OAttachments := OSendMail.Attachments; OAttachment := OAttachments.Add(BSTRConverterAttachFileName); END; END;
5) At least you have do define and fill up an array in your mail-calling function.
This should work fine
I hope, this tiny little code will help you and others to send multiple attachments from MS Dynamics.Who wants to live in ease,
should not communicate his knowledge,
and not believe he knows form hearsay.0 -
Please inform me how to create the variables
BSTRConverterAttachFileName
OAttachments
OSendMail
OAttachment0
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