Sending MAPI message works from .vbs, but not in ASP 
Author Message
 Sending MAPI message works from .vbs, but not in ASP

Below is my script that sends a mapi message from an asp
page.
It needs to be in MAPI format because there are scripts on
the server that run against the message.

I can run this fine from a command line, but it will not
run from an ASP page.  I get no error, but nothing gets
sent.
Any ideas?


<% option explicit %>
<%On Error Resume Next%>

<%
' Setup constants and global variables
first                                       '

Dim MessageClass, CdoPR_MESSAGE_CLASS
Dim CreatorDN, ExServer
Dim objSession, objMessage, objFields, objOneRecip

' --- servername ---
ExServer = "Sun"

'SMTP address of the account creator

' --- MAPI INFO ---
MessageClass = "IPM.Note.ExMS.Create"
CdoPR_MESSAGE_CLASS = &H001A001E

' --- GET USERNAME FOR MAILBOX ---
Dim sNTLogon, splitsNTLogon, LogonUser
sNTLogon = Request.ServerVariables("LOGON_USER")
splitsNTlogon = Split(sNTLogon,"/")
LogonUser = splitsNTlogon(Ubound(splitsNTlogon))

' --- MAPI MESSAGE ---

'opens MAPI session - USES CDO1.21  GETS POINTER TO
INTIALIZE
Set objSession = Server.CreateObject("MAPI.Session")

'LOGIN to session or as a regular user
objSession.Logon ,,False,True,0,True,ExServer & vbLf &
LogonUser

' create a message and fill in its properties
Set objMessage = objSession.Outbox.Messages.Add
objMessage.Subject = "Create Account Request"
objMessage.Text = "Create Account Request"
Set objFields = objMessage.Fields
objFields.SetNamespace ""   'SETS PREDEFINED

'these MAPI properties should be in the message - MAPI
TAGS NEEDED BY CDO
Set objField = objFields.Add (CdoPR_MESSAGE_CLASS,
MessageClass)
Set objField = objFields.Add ("MS_EXCHANGE_01",
vbBoolean , True )

' create the recipient - TO WHOM TO SEND THE MESSAGE -
SENDS TO EXMS CREATE OR UPDATE
Set objOneRecip = objMessage.Recipients.Add
objOneRecip.Type = 1         'CdoTo
objOneRecip.Name = CreatorDN

' get MAPI to determine complete e-mail address
objOneRecip.Resolve

'send message  HIDES DIALOG
objMessage.Send showDialog = False

'logoff MAPI session
objSession.Logoff

response.write "***** Finished"
%>



Wed, 01 Sep 2004 02:35:36 GMT  
 Sending MAPI message works from .vbs, but not in ASP
Are you using NT Authentication with anonymous access disabled?

--

=========================
Kyle M. Burns, MCSD, MCT


Quote:
> Below is my script that sends a mapi message from an asp
> page.
> It needs to be in MAPI format because there are scripts on
> the server that run against the message.

> I can run this fine from a command line, but it will not
> run from an ASP page.  I get no error, but nothing gets
> sent.
> Any ideas?


> <% option explicit %>
> <%On Error Resume Next%>

> <%
> ' Setup constants and global variables
> first                                       '

> Dim MessageClass, CdoPR_MESSAGE_CLASS
> Dim CreatorDN, ExServer
> Dim objSession, objMessage, objFields, objOneRecip

> ' --- servername ---
> ExServer = "Sun"

> 'SMTP address of the account creator

> ' --- MAPI INFO ---
> MessageClass = "IPM.Note.ExMS.Create"
> CdoPR_MESSAGE_CLASS = &H001A001E

> ' --- GET USERNAME FOR MAILBOX ---
> Dim sNTLogon, splitsNTLogon, LogonUser
> sNTLogon = Request.ServerVariables("LOGON_USER")
> splitsNTlogon = Split(sNTLogon,"/")
> LogonUser = splitsNTlogon(Ubound(splitsNTlogon))

> ' --- MAPI MESSAGE ---

> 'opens MAPI session - USES CDO1.21  GETS POINTER TO
> INTIALIZE
> Set objSession = Server.CreateObject("MAPI.Session")

> 'LOGIN to session or as a regular user
> objSession.Logon ,,False,True,0,True,ExServer & vbLf &
> LogonUser

> ' create a message and fill in its properties
> Set objMessage = objSession.Outbox.Messages.Add
> objMessage.Subject = "Create Account Request"
> objMessage.Text = "Create Account Request"
> Set objFields = objMessage.Fields
> objFields.SetNamespace ""   'SETS PREDEFINED

> 'these MAPI properties should be in the message - MAPI
> TAGS NEEDED BY CDO
> Set objField = objFields.Add (CdoPR_MESSAGE_CLASS,
> MessageClass)
> Set objField = objFields.Add ("MS_EXCHANGE_01",
> vbBoolean , True )

> ' create the recipient - TO WHOM TO SEND THE MESSAGE -
> SENDS TO EXMS CREATE OR UPDATE
> Set objOneRecip = objMessage.Recipients.Add
> objOneRecip.Type = 1         'CdoTo
> objOneRecip.Name = CreatorDN

> ' get MAPI to determine complete e-mail address
> objOneRecip.Resolve

> 'send message  HIDES DIALOG
> objMessage.Send showDialog = False

> 'logoff MAPI session
> objSession.Logoff

> response.write "***** Finished"
> %>



Wed, 01 Sep 2004 06:36:13 GMT  
 Sending MAPI message works from .vbs, but not in ASP
yes - in fact, if i put a "response.write logonuser" statement, it
returns the logon user just fine.  and it goes thru the whole script and
print finsihed at the end also.  it just never sends a mapi message and
never reports and error.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Wed, 01 Sep 2004 07:21:12 GMT  
 Sending MAPI message works from .vbs, but not in ASP
No _ I am using Basic Auth -I get a prompt for a username.
I am able to "response.write LogonUser", but I get the
error:

Collaboration Data Objects error '000004f9'

The information store could not be opened. [MAPI 1.0 -
[MAPI_E_LOGON_FAILED(80040111)]]

once it gets to the line that says "Set objMessage =
objSession.Outbox.Messages.Add "

I am straiing my brain to figure out this permission stuff
from within IE/ASP.  I can do this fine from a command
line, but who wants to work like that?

Quote:
>-----Original Message-----
>Are you using NT Authentication with anonymous access
disabled?

>--

>=========================
>Kyle M. Burns, MCSD, MCT



>> Below is my script that sends a mapi message from an asp
>> page.
>> It needs to be in MAPI format because there are scripts
on
>> the server that run against the message.

>> I can run this fine from a command line, but it will not
>> run from an ASP page.  I get no error, but nothing gets
>> sent.
>> Any ideas?


>> <% option explicit %>
>> <%On Error Resume Next%>

>> <%
>> ' Setup constants and global variables
>> first                                       '

>> Dim MessageClass, CdoPR_MESSAGE_CLASS
>> Dim CreatorDN, ExServer
>> Dim objSession, objMessage, objFields, objOneRecip

>> ' --- servername ---
>> ExServer = "Sun"

>> 'SMTP address of the account creator

>> ' --- MAPI INFO ---
>> MessageClass = "IPM.Note.ExMS.Create"
>> CdoPR_MESSAGE_CLASS = &H001A001E

>> ' --- GET USERNAME FOR MAILBOX ---
>> Dim sNTLogon, splitsNTLogon, LogonUser
>> sNTLogon = Request.ServerVariables("LOGON_USER")
>> splitsNTlogon = Split(sNTLogon,"/")
>> LogonUser = splitsNTlogon(Ubound(splitsNTlogon))

>> ' --- MAPI MESSAGE ---

>> 'opens MAPI session - USES CDO1.21  GETS POINTER TO
>> INTIALIZE
>> Set objSession = Server.CreateObject("MAPI.Session")

>> 'LOGIN to session or as a regular user
>> objSession.Logon ,,False,True,0,True,ExServer & vbLf &
>> LogonUser

>> ' create a message and fill in its properties
>> Set objMessage = objSession.Outbox.Messages.Add
>> objMessage.Subject = "Create Account Request"
>> objMessage.Text = "Create Account Request"
>> Set objFields = objMessage.Fields
>> objFields.SetNamespace ""   'SETS PREDEFINED

>> 'these MAPI properties should be in the message - MAPI
>> TAGS NEEDED BY CDO
>> Set objField = objFields.Add (CdoPR_MESSAGE_CLASS,
>> MessageClass)
>> Set objField = objFields.Add ("MS_EXCHANGE_01",
>> vbBoolean , True )

>> ' create the recipient - TO WHOM TO SEND THE MESSAGE -
>> SENDS TO EXMS CREATE OR UPDATE
>> Set objOneRecip = objMessage.Recipients.Add
>> objOneRecip.Type = 1         'CdoTo
>> objOneRecip.Name = CreatorDN

>> ' get MAPI to determine complete e-mail address
>> objOneRecip.Resolve

>> 'send message  HIDES DIALOG
>> objMessage.Send showDialog = False

>> 'logoff MAPI session
>> objSession.Logoff

>> response.write "***** Finished"
>> %>

>.



Fri, 03 Sep 2004 23:50:16 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Send Mapi message from ASP script

2. MAPI message Send method puts message in Outbox but it isn't actually sent

3. MAPI - Exchange Server does not send e-mail message

4. MAPI - Sending a mail message to a recip NOT in any address book

5. MAPI - Sending a mail message to a recip NOT in any address book

6. Sample microsoft code not working for me - sending messages

7. Mapi: Send method will not send

8. CreateObject(MAPI.Session) DOES NOT work on Windows 95

9. MAPI Script does not work for a certain curcumstances

10. MAPI.Session with VBS in .asp page?

11. Sending/receiving email messages with MAPI

12. Sending a message width MAPI in VB 6.0

 

 
Powered by phpBB® Forum Software