09-06-2016, 03:07 PM
This is a working sample, just substitute all necessary items before using it.
Macro C# Send Email with Yahoo Mail
Macro C# Send Email with Yahoo Mail
;To get encryptedPassword, just run Gintaras' "Encrypted password generator" macro to generate it
str encryptedPassword="MpLtzu1l0Q1gze3/t3lvmOBEjEkGNibTBQ=="
str password.decrypt(1|4 encryptedPassword "myEncryptionKey")
;out F"password = {password}"
str emailTo="recipient email"
str subject="Subject"
str body="Body"
CsFunc("" password emailTo subject body)
#ret
//C# code
using System;
using System.Net;
using System.Net.Mail;
public class Email
{
,static public void Send(string password, string emailTo, string subject, string body)
,{
,,string smtpAddress = "smtp.mail.yahoo.com";
,,int portNumber = 587;
,,bool enableSSL = true;
,,string emailFrom = "YourEmail@yahoo.com";
,,using (MailMessage mail = new MailMessage())
,,{
,,,mail.From = new MailAddress(emailFrom);
,,,mail.To.Add(emailTo);
,,,mail.Subject = subject;
,,,mail.Body = body;
,,,mail.IsBodyHtml = true; // Can set to false, if you are sending pure text.
,,
,,,mail.Attachments.Add(new Attachment(@"C:\Temp\File1.txt"));
,,,mail.Attachments.Add(new Attachment(@"C:\Temp\File2.txt"));
,,
,,,using (SmtpClient smtp = new SmtpClient(smtpAddress, portNumber))
,,,{
,,,,smtp.Credentials = new NetworkCredential(emailFrom, password);
,,,,smtp.EnableSsl = enableSSL;
,,,,smtp.Send(mail);
,,,}
,,}
,}
}