combit List & Label 29 - .NET Help
combit.Reporting Namespace / MailJob Class / AdditionalOptions Property


In This Topic
    AdditionalOptions Property
    In This Topic

    Allows to define some additional mail options e.g. for sending via SMTP or GRPAH.

    These options can be found in the Programmer's Reference for "Export.Mail..." (see also Setting Mail Parameters by Code).

    Syntax
    'Declaration
     
    
    Public ReadOnly Property AdditionalOptions As Dictionary(Of String,String)
    public Dictionary<string,string> AdditionalOptions {get;}
    public:
    property Dictionary<String^,String^>^ AdditionalOptions {
       Dictionary<String^,String^>^ get();
    }
    Example

    Shows sending mail via the SMTP protocol.

     // Instantiate mail job
     using(MailJob mailJob = new MailJob())
     {
         // Set options
         mailJob.AttachmentList.Add(@"<Path>\report.pdf");
         mailJob.To = "<To>";
         mailJob.Subject = "Here is the report";
         mailJob.Body = "Please note the attachment.";
         mailJob.ShowDialog = true;
    
        // Set SMTP options
         mailJob.Provider = "SMTP";
         mailJob.AdditionalOptions.Add("SMTP.ServerAddress", "<ServerAdresse>");
         mailJob.AdditionalOptions.Add("SMTP.ServerUser", "<ServerBenutzer>");
         mailJob.AdditionalOptions.Add("SMTP.ServerPassword", "<ServerPasswort>");
    
        // Send eMail
         mailJob.Send();
     }
    
    ' Instantiate mail job
     Using mailJob As New MailJob()
    
        ' Set options
         mailJob.AttachmentList.Add("<Path>\report.pdf")
         mailJob.To = "<To>"
         mailJob.Subject = "Here is the report"
         mailJob.Body = "Please note the attachment."
         mailJob.ShowDialog = True
         
         ' Set SMTP options
         mailJob.Provider = "SMTP"
         mailJob.AdditionalOptions.Add("SMTP.ServerAddress", "<ServerAdresse>")
         mailJob.AdditionalOptions.Add("SMTP.ServerUser", "<ServerBenutzer>")
         mailJob.AdditionalOptions.Add("SMTP.ServerPassword", "<ServerPasswort>")
         
         ' Send mail
         mailJob.Send()
    
    End Using
    

    Shows sending mail via the Microsoft GRAPH.

    // Mailjob instanzieren
    using(MailJob mailJob = new MailJob())
    {
        // Set options
        mailJobLL.From = "<From>";
        mailJobLL.To = "<To>";
        mailJobLL.Subject = "My Test Message";
        mailJobLL.BodyHtml = File.ReadAllText(@"C:\temp\mailcontent.html");
        
        // Set GRAPH options...
        mailJob.Provider = "GRAPH";
        
        // ... use bearer token authentication
        mailJob.AdditionalOptions.Add("Graph.AuthType", "3"); 
        
        // ... client id of the app
        mailJob.AdditionalOptions.Add("Graph.ClientId", "697517f7-70dd-4ef9-8a5c-xxxxxxxxxxxx");
        
        // ... azure domain
        mailJob.AdditionalOptions.Add("Graph.TenantId", "fe0ef3d4-0076-4c1f-9b6c-xxxxxxxxxxxx");
        
        // ... redirect here
        mailJob.AdditionalOptions.Add("Graph.RedirectUri", "msal697517f7-70dd-4ef9-xxxxxxxxxxxx://auth");
        
        // ... we either need user name or user object id
        mailJob.AdditionalOptions.Add("Graph.UserName", "<Your Graph Username>");
        mailJob.AdditionalOptions.Add("Graph.UserObjectId", "34567890-3456-3456-3456-xxxxxxxxxxxx");
        
        // ... and of course the promised token that we previously acquired
        mailJob.AdditionalOptions.Add("Graph.BearerToken", "xxxxxxxxxxxx");
        
        // Send mail
        mailJob.Send();
    }
    
    ' Mailjob instanziere
    Using mailJob As New MailJob()
    
        ' Set options
        mailJobLL.From = "<From>"
        mailJobLL.To = "<To>"
        mailJobLL.Subject = "My Test Message"
        mailJobLL.BodyHtml = File.ReadAllText(@"C:\temp\mailcontent.html")
        
        ' Set GRAPH options...
        mailJob.Provider = "GRAPH"
        
        ' ... use bearer token authentication
        mailJob.AdditionalOptions.Add("Graph.AuthType", "3");
        
        ' ... client id of the app
        mailJob.AdditionalOptions.Add("Graph.ClientId", "697517f7-70dd-4ef9-8a5c-xxxxxxxxxxxx")
        
        ' ... azure domain
        mailJob.AdditionalOptions.Add("Graph.TenantId", "fe0ef3d4-0076-4c1f-9b6c-xxxxxxxxxxxx")
        
        ' ... redirect here
        mailJob.AdditionalOptions.Add("Graph.RedirectUri", "msal697517f7-70dd-4ef9-xxxxxxxxxxxx://auth")
        
        ' ... we either need user name or user object id
        mailJob.AdditionalOptions.Add("Graph.UserName", "<Your Graph Username>")
        mailJob.AdditionalOptions.Add("Graph.UserObjectId", "34567890-3456-3456-3456-xxxxxxxxxxxx")
        
        ' ... and of course the promised token that we previously acquired
        mailJob.AdditionalOptions.Add("Graph.BearerToken", "xxxxxxxxxxxx")
        
        ' Send mail
        mailJob.Send()
    
    End Using
    

    One more sample for sending mail is shown here: Sending mail.

    Requirements

    Platforms: Windows 10 (Version 21H2 - 23H2), Windows 11 (21H2 - 22H2), Windows Server 2016 - 2022
    .NET: .NET Framework 4.8, .NET 6, .NET 7, .NET 8

    See Also