Does anyone know a working SMTP mail send source code with attachement? I looked all over the internet and found this:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <iostream.h>
#include <winuser.h>
#include <iostream> 
 
int main()
{
    #define fromAddress email    
#define MailConst.Username Name    
#define MailConst.Password password
    #define recipient someone@gmail.com
    #define attachmentFilename calc.exe    
#define MailConst.SmtpServer smtp.gmail.com
    
    
public static void SendMail(string recipient, string subject, string body, string attachmentFilename)
    {
        SmtpClient smtpClient = new SmtpClient();
        NetworkCredential basicCredential = new NetworkCredential(MailConst.Username, MailConst.Password);
        MailMessage message = new MailMessage();
        MailAddress fromAddress = new MailAddress(MailConst.Username);
        // setup up the host, increase the timeout to 5 minutes
        smtpClient.Host = MailConst.SmtpServer;
        smtpClient.UseDefaultCredentials = false;
        smtpClient.Credentials = basicCredential;
        smtpClient.Timeout = (60 * 5 * 1000);
        message.From = fromAddress;
        message.Subject = Something;
        message.IsBodyHtml = false;
        message.Body = Something;
        message.To.Add(recipient);
        if (attachmentFilename != null)
            message.Attachments.Add(new Attachment(attachmentFilename));
        smtpClient.Send(message);
    }
I get a error at public line.