HOWTO: Call a Visual Basic ActiveX DLL to Send MailID: Q200150
|
This article shows how to write a Visual Basic ActiveX DLL to send an e-mail message using Collaboration Data Objects (CDO). It also shows how to call this DLL from C code.
Use the following steps to create a Microsoft Visual Basic ActiveX DLL Project:
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
// 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;
}
Additional query words: kbDSupport kbCDO kbCDO110 kbCDO120 kbMsg kbActMsg
Keywords : kbActMsg kbCDO110 kbCDO120 kbMsg kbVBp kbVC kbGrpMsg
Version : WINDOWS:1.1,1.2
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: April 7, 1999