This is Win32 only (relies on ATL), however if you are running under *nix, then you can just use system() to call sendto or sendmail manually, which is IMHO far easier.
This should help with anyone programming 1.3 interfaces to SL. (like my winamp plugin for example). Please however remember that at the moment, the ID for an attached object appears to change each time you teleport, so you will want to include an easy way to change the id from within your app, or use a POP3 interface to retrieve the ID manually.
This function has been tested under Windows 2K proffessional, Win2K server & Win2K3 Server, however I am unsure if CMimeMessage/CSMTPConnection is implemented in the Win9X series.
The main function
CODE
void send_email(char* message, char* to, char* subject, char* smtp_server,char* from_address, char* from_name)
{
CMimeMessage msg;
msg.SetSender(from_address);
msg.SetSenderName(from_name);
msg.AddRecipient(to,"Object");
msg.SetSubject(subject);
msg.AddText(message);
CSMTPConnection connection;
connection.Connect(smtp_server);
connection.SendMessage(msg);
Sleep(1000); // Sleep so an infinite loop wont cause a large spam attack. Remove if you know what your doing.
}
Precompiled Header (usually StdAfx.h)
CODE
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__CFF738C2_CBB7_11D4_AB00_0010A4EC0A5C__INCLUDED_)
#define AFX_STDAFX_H__CFF738C2_CBB7_11D4_AB00_0010A4EC0A5C__INCLUDED_
#if _MSC_VER < 1000
#pragma once
#endif // _MSC_VER > 1000
#define WIN32_LEAN_AND_MEAN 0 // Exclude rarely-used stuff from Windows headers
#define EXTRA_LEAN 0 // Exclude more crap
#include <stdio.h>
#include <windows.h>
#include <atlbase.h>
#include <atlcom.h>
#include <atlisapi.h>
#include <atlstencil.h>
#include <atlutil.h>
#include <atlsmtpconnection.h>
// TODO: reference additional headers your program requires here
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__CFF738C2_CBB7_11D4_AB00_0010A4EC0A5C__INCLUDED_)
Example use
CODE
#include "StdAfx.h"
void send_email(char* message, char* to, char* subject, char* smtp_server,char* from_address, char* from_name)
{
CMimeMessage msg;
msg.SetSender(from_address);
msg.SetSenderName(from_name);
msg.AddRecipient(to,"Object");
msg.SetSubject(subject);
msg.AddText(message);
CSMTPConnection connection;
connection.Connect(smtp_server);
connection.SendMessage(msg);
Sleep(1000); // Sleep so an infinite loop wont cause a large spam attack. Remove if you know what your doing.
}
int main() {
send_email("Hello World", "hello@world.com", "Hello!", "mail.xyz.com","my_email_address@email.com","Me");
return 0;
}