Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_components thread: CDO/MAPI Problems


Message #1 by "Colin Gourlay" <cgourlay@h...> on Thu, 22 Nov 2001 11:28:21 +0000
I am writing an ActiveX DLL that is to essentially provide basic mail 

functionality.



This DLL is actually an Error Handling Component so can (expected to) be 

used in ASP development as well as Win32 Desktop development.



I used the MAPI controls that ship with VB6 Enterprise Edition to create a 

method that is essentially a wrapper function that delivers e-mail according 

to the parameters passed in.



PROBLEM:



When I use this component from another VB Project it works as expected - yet 

when I try and do the same (using the same parameters) in an ASP page no 

mail is delivered at all.



I changed this to using CDO (by referencing the library through the Visual 

Basic IDE) but still no joy via the ASP page.



Can anyone please give me some advice as to where I am going wrong?



I have provided some sample code below in the hope that this helps a little:



PS Running Windows 2000 Service Pack 2, Visual Studio (Enterprise) - SP5



ASP Page

========



Response.Write ("Generating an e-mail to be sent")



objErrorComponent.AddError "Err Number", "Err Description", 

"recipient@s...", "Subject Heading", "Body Text"



Response.Write ("Support E-Mail sent")



VB Method

=========

frmActiveXContainer.mpsMAPISession.SignOn



  If frmActiveXContainer.mpsMAPISession.SessionID <> m_c_lngInvalidSession 

Then



  With frmActiveXContainer.mpmMAPIMessages



      .SessionID = frmActiveXContainer.mpsMAPISession.SessionID

      .Compose

      .RecipAddress = RecipientEMailAddress

      .MsgSubject = MessageSubject

      .MsgNoteText = Message

      .ResolveName

      .Send



  End With



Thank you for taking the time to read this.



Colin



_________________________________________________________________

Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp



Message #2 by "Bruce J. Pezzlo" <bpezzlo@p...> on Thu, 22 Nov 2001 08:53:21 -0500
It depends what agent you are using to send mail.  If it is the

webserver, make sure you have setup SMTP service on the web box.



From your code, it looks like you might be logging into an email server

like exchange?



Here is an example in asp / vbscript that sends mail using cdo when

using the local smtp service running on the webserver.



<!-- Example starts here -->



dim oCDO

Set oCDO =3D CreateObject("CDONTS.NewMail")

With oCDO

	.From =3D "validemail@y..."

	.To =3D "anyaddress@a..."

	.Subject =3D "Yalsjdflkjas" & strSomeVariable

	.Body =3D "Blah Blah" & strSomeOtherVariable

	.MailFormat =3D 0 ' cdo constant for mime

	.BodyFormat =3D 0 ' cdo constanct for text

	.Send 'bingo, your mail sent using smtp service on box.

End With

Set oCDO =3D Nothing



<!-- Example ends here -->





Bruce





---

Bruce Pezzlo

MCSD & MCDBA

President

PLUM Computer Consulting, Inc.

(617) 266 - 1942 x201

Fax: (617) 267 - 0895

bpezzlo@p...








  Return to Index