Posts Tagged ‘ Mail

Dynamics AX’ta BCC (Gizli) mail nasıl gönderilir?

Merhaba

Ax içinden Bcc mail göndermek için SYSMailer sınıfına bazı eklemeler yapmak gerekiyor.

Aşağıdaki metotları SYSMailer sınıfına ekleyelim.

//DMR FD
SysMailerAddressField bccs()
{
    InteropPermission permission = new InteropPermission(InteropKind::ComInterop);

    permission.assert();

    //BP Deviation Documented
    return SysMailerAddressField::create(_com,SysmailerAddressFieldType::Bcc);
}

.

// DMR FD
SysMailerAddressField tosBCC()
{
    ;
    return SysMailerAddressField::create(_com,SysmailerAddressFieldType::Bcc);
}

.

// DMR FD
public void quickSendBcc(str fromAddr, str toAddr, str subject,
 str body, str cc='',str bcc='', str attachments='')
{
    SysMailerAddressField tos;
    SysMailerAddressField ccs;
    SysMailerAddressField bccs;
    SysMailerAttachments mailAttachments;
    SysEmailParameters parameters;

    List emailAddresses;
    ListEnumerator enum;
    ;

    this.fromAddress(fromAddr);

    tos = this.tos();
    emailAddresses = SysEmailDistributor::splitEmail(toAddr);
    enum = emailAddresses.getEnumerator();
    while(enum.moveNext())
    {
        tos.appendAddress(enum.current());
    }

    this.subject(subject);
    this.htmlBody(body);

    if (!prmisdefault(cc))
    {
        ccs = this.ccs();
        ccs.appendAddress(cc);
    }

    if (!prmisdefault(bcc))
    {
        bccs = this.bccs();
        bccs.appendAddress(bcc);
    }

    if (!prmisdefault(attachments))
    {
        mailAttachments = this.attachments();
        mailAttachments.add(attachments);
    }

    this.priority(1);

    parameters = SysEmailParameters::find();

    if (parameters.smtpRelayServerName)
    {
        this.SMTPRelayServer(parameters.smtpRelayServerName,parameters.smtpPortNumber,
              parameters.smtpUserName,SysEmailParameters::password(),parameters.ntlm);
    }

    this.sendMail();

}

Bu eklemelerde sonra şöyle bir örnekle mail gönderimini test edebiliriz.

static void FD_SendMailSampleCcandBcc(Args _args)
{
    SysMailer   mailer;
    str         toEmail     = "fatih.demirci@aaaa.com";
    str         fromEmail   = "iletisim@aaaa.com";
    str         cc          = "aaaaa@aaaa.com";
    str         bcc         = "bbbb@aaaa.com";
    str         subject     = "Email konusu";
    str         body        = "Email içeriği";

    ;
    mailer = new SysMailer();
    mailer.quickSendBcc( fromEmail, toEmail, subject, body, cc , bcc);

}

Selamlar.