pageextension 50100 "Task Card" extends "Task Card"
{
actions
{
addafter(MakePhoneCall)
{
action("Send Invitations")
{
ApplicationArea = RelationshipMgmt;
Caption = 'Send Invitations';
trigger OnAction()
var
Mail: Codeunit "Mail Management";
MailItem: Record "Email Item";
Attendee: record Attendee;
begin
Attendee.SetRange("To-do No.", Rec."No.");
Attendee.SetRange("Send Invitation", true);
Attendee.SetRange("Invitation Sent", false);
if Attendee.FindSet() then
repeat
MailItem.SetBodyText(StrSubstNo('Hi %1, please take part.', Attendee."Attendee Name"));
MailItem.Subject := StrSubstNo('%1 - %2 - %3', Rec.Description, Rec.Date, Rec."Start Time");
MailItem."Send to" := GetMailAddress(Attendee);
if not Mail.CheckValidEmailAddress(MailItem."Send to") then
error('Mail Address not valid.');
Mail.SetHideMailDialog(true);
if not Mail.Send(MailItem, "Email Scenario"::Notification) then
error('Error occured when sending Mails. Please check logging.');
until Attendee.Next() = 0;
end;
}
}
}
local procedure GetMailAddress(Attendee: record Attendee): Text
var
Contact: Record Contact;
SalesPerson: Record "Salesperson/Purchaser";
begin
if Attendee."Attendee Type" = Attendee."Attendee Type"::Contact then
if Contact.Get(Attendee."Attendee No.") then
exit(Contact."E-Mail");
if Attendee."Attendee Type" = Attendee."Attendee Type"::Salesperson then
if SalesPerson.Get(Attendee."Attendee No.") then
exit(SalesPerson."E-Mail");
end;
}