Tutorial how to send mail in max via maxscript and dotnet

I have written a function that can send mail in max easy (More info). If you want to write it yourselve, here a post how you can do it…

First : set up message. Create a new MailMessage and set up the params.

MailMessage = dotNetObject "System.Net.Mail.MailMessage"
MailAdressFrom = dotNetObject "System.Net.Mail.MailAddress" FromAdress
MailMessage.From = MailAdressFrom
MailAdressTo = dotNetObject "System.Net.Mail.MailAddress" ToAdress
MailMessage.To.Add MailAdressTo
MailMessage.Subject = Subject
MailMessage.Body = Text

Add attachment (Optional). You can add more than one attachment. Note that the size of an attachment is limited.  Gmail can send and recieve messages up to 25 megabytes (MB) in size. But in general, 10MB is considered safe for the maximum size of an email

MailAttachment = dotNetObject "System.Net.Mail.Attachment" AttachFile

Send mail using Gmail or Hotmail.

Client = dotNetObject "System.Net.Mail.SmtpClient"

Client.Host = "smtp.gmail.com"

/*for hotmail use
Client.Host = "smtp.live.com"

 Client.EnableSsl = true;
 NetworkCred = dotNetObject "System.Net.NetworkCredential"
 NetworkCred.UserName = FromAdress
 NetworkCred.Password = Password
 Client.UseDefaultCredentials = true
 Client.Credentials = NetworkCred
 Client.Port = 587
 Client.Send MailMessage

Possible to send with a custom adress, you just have to set the parameters.

Client = dotNetObject "System.Net.Mail.SmtpClient"
 Client.Host = Host--"uit.telenet.be"
 NetworkCred = dotNetObject "System.Net.NetworkCredential"
NetworkCred.UserName = Username
 NetworkCred.Password = Password;
 Client.UseDefaultCredentials = true;
 Client.Credentials = NetworkCred;
Client.Port = 25;

1 Comment

Michael · July 21, 2013 at 4:49 am

brilliant! just a little fiddling on my part and got it working with my domain. This is a huge lifesaver!

Leave a Reply

Your email address will not be published. Required fields are marked *