BCC using SMTPMail
 
            
                
                    Red-Eagle                
                
                    Member Posts: 107                
            
                        
            
                    I have a form with has the following code:
TESTFIELD("Buy-from Vendor No.");
Vendor.GET("Buy-from Vendor No.");
IF Vendor."E-Mail for Purch. Order" = '' THEN
CurrReport.SKIP;
EMailOnBehalf.SETRANGE(Usage, EMailOnBehalf.Usage::"Purchase Order");
IF EMailOnBehalf.FINDFIRST THEN BEGIN
EMailOnBehalf.TESTFIELD("Send On Behalf Of E-mail");
SMTPMail.CreateMessage(
EMailOnBehalf."Send On Behalf Of Name",
EMailOnBehalf."Send On Behalf Of E-mail",
Vendor."E-Mail for Purch. Order",
STRSUBSTNO(Text000, "No."),
'',
FALSE);
END ELSE
SMTPMail.CreateMessage(
CompanyInfo.Name,
CompanyInfo."E-Mail",
Vendor."E-Mail for Purch. Order",
STRSUBSTNO(Text000, "No."),
'',
FALSE);
EMailBodyText.SETRANGE(Usage, EMailBodyText.Usage::"Purchase Order");
EMailBodyText.SETRANGE("Language Code", "Language Code");
IF EMailBodyText.ISEMPTY THEN
EMailBodyText.SETRANGE("Language Code", '');
IF EMailBodyText.FINDSET THEN BEGIN
REPEAT
SMTPMail.AppendBody(STRSUBSTNO(EMailBodyText.Text + CrLf, CompanyInfo.Name))
UNTIL EMailBodyText.NEXT = 0;
END;
PurchaseHeader.COPY("Purchase Header");
CASE UseDefaultReportSelection OF
TRUE: GetDefaultReportSelection(TempReportSelections.Usage::"P.Order", TempReportSelections);
FALSE: DocPrint.GetReportSelection(TempReportSelections.Usage::"P.Order", TempReportSelections, TRUE);
END;
IF TempReportSelections.FINDFIRST THEN
REPEAT
TempFileName := STRSUBSTNO('%1.%2', "No.", TempReportSelections.Sequence);
SaveReportAsPDF.PurchaseHeader(PurchaseHeader, TempReportSelections."Report ID", TempFolderName, TempFileName, 30000);
SMTPMail.AddAttachment(STRSUBSTNO('%1\%2.pdf', TempFolderName, TempFileName));
UNTIL TempReportSelections.NEXT = 0;
DocumentRelation.SETRANGE("Document Type", DocumentRelation."Document Type"::"Purchase Order");
DocumentRelation.SETRANGE("No.", "Purchase Header"."No.");
IF DocumentRelation.FINDSET THEN
REPEAT
IF Document.GET(DocumentRelation."Related Document No.") THEN
IF Document.FullFileName <> '' THEN
IF FILE.EXISTS(Document.FullFileName) THEN
SMTPMail.AddAttachment(Document.FullFileName)
UNTIL DocumentRelation.NEXT = 0;
SMTPMail.Send;
Now I want to change this that it will also send a e-mail using BCC, so we can see what we have send and when.
                TESTFIELD("Buy-from Vendor No.");
Vendor.GET("Buy-from Vendor No.");
IF Vendor."E-Mail for Purch. Order" = '' THEN
CurrReport.SKIP;
EMailOnBehalf.SETRANGE(Usage, EMailOnBehalf.Usage::"Purchase Order");
IF EMailOnBehalf.FINDFIRST THEN BEGIN
EMailOnBehalf.TESTFIELD("Send On Behalf Of E-mail");
SMTPMail.CreateMessage(
EMailOnBehalf."Send On Behalf Of Name",
EMailOnBehalf."Send On Behalf Of E-mail",
Vendor."E-Mail for Purch. Order",
STRSUBSTNO(Text000, "No."),
'',
FALSE);
END ELSE
SMTPMail.CreateMessage(
CompanyInfo.Name,
CompanyInfo."E-Mail",
Vendor."E-Mail for Purch. Order",
STRSUBSTNO(Text000, "No."),
'',
FALSE);
EMailBodyText.SETRANGE(Usage, EMailBodyText.Usage::"Purchase Order");
EMailBodyText.SETRANGE("Language Code", "Language Code");
IF EMailBodyText.ISEMPTY THEN
EMailBodyText.SETRANGE("Language Code", '');
IF EMailBodyText.FINDSET THEN BEGIN
REPEAT
SMTPMail.AppendBody(STRSUBSTNO(EMailBodyText.Text + CrLf, CompanyInfo.Name))
UNTIL EMailBodyText.NEXT = 0;
END;
PurchaseHeader.COPY("Purchase Header");
CASE UseDefaultReportSelection OF
TRUE: GetDefaultReportSelection(TempReportSelections.Usage::"P.Order", TempReportSelections);
FALSE: DocPrint.GetReportSelection(TempReportSelections.Usage::"P.Order", TempReportSelections, TRUE);
END;
IF TempReportSelections.FINDFIRST THEN
REPEAT
TempFileName := STRSUBSTNO('%1.%2', "No.", TempReportSelections.Sequence);
SaveReportAsPDF.PurchaseHeader(PurchaseHeader, TempReportSelections."Report ID", TempFolderName, TempFileName, 30000);
SMTPMail.AddAttachment(STRSUBSTNO('%1\%2.pdf', TempFolderName, TempFileName));
UNTIL TempReportSelections.NEXT = 0;
DocumentRelation.SETRANGE("Document Type", DocumentRelation."Document Type"::"Purchase Order");
DocumentRelation.SETRANGE("No.", "Purchase Header"."No.");
IF DocumentRelation.FINDSET THEN
REPEAT
IF Document.GET(DocumentRelation."Related Document No.") THEN
IF Document.FullFileName <> '' THEN
IF FILE.EXISTS(Document.FullFileName) THEN
SMTPMail.AddAttachment(Document.FullFileName)
UNTIL DocumentRelation.NEXT = 0;
SMTPMail.Send;
Now I want to change this that it will also send a e-mail using BCC, so we can see what we have send and when.
0                
            Answers
- 
            SMTPMail.AddBCC(emailaddress)
 You can pick up emailadress from Salesperson code0
- 
            [Topic moved from 'NAV 2009' forum to 'NAV/Navision' forum]Regards,Alain Krikilion
 No PM,please use the forum. || May the <SOLVED>-attribute be in your title!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
- 323 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

