Article ID: 200150
Article Last Modified on 7/19/2005
Public Function sendmail(Recip As String, Subject As String)
Dim osession As MAPI.Session
Dim omessage As Message
Dim oRecip As Recipient
Set osession = CreateObject("MAPI.Session")
osession.Logon
Set omessage = osession.Outbox.Messages.Add
omessage.Subject = Subject
Set oRecip = omessage.Recipients.Add(Recip)
oRecip.Resolve
omessage.Text = "Testing"
omessage.Send , True
osession.Logoff
End Function
The following C code (Win 32 Application) is used to create and call the ActiveX DLL.
// activexdll1.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include <objbase.h>
// Change to include your DLL
#import "Project2.dll" no_namespace
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// Initialize COM
CoInitialize(NULL);
// Change to the name of the person
// you wish to send the message
_variant_t name ("alias");
_variant_t subject ("Testing ActiveX DLL");
// Create an instance of the ActiveX object
// Where Class1 is the class module of your Project2
_Class1Ptr oDLL("Project2.Class1");
oDLL->sendmail(&name.bstrVal,&subject.bstrVal);
oDLL = NULL;
CoUninitialize();
return 0;
}
Keywords: kbhowto kbmsg kbfaq KB200150