|
 |
asp_cdo thread: Can't Send Mail With Exchange Server
Message #1 by "Ben Anderson" <banderson87@h...> on Mon, 17 Jul 2000 20:34:24
|
|
I can't send mail with Exchange Server. I used the code from the
Proffessional ASP 3.0 book, but i still can't get it to work. Here is the
code that i used:
'declare the mail variables
dim mailbody,recip,newSession,newMessage,mailbox,server,profile,address
mailbody = width & "<BR>" & height & "<BR>" & color & "<BR>" & material
mailbox = request.form("mailbox")
server = request.form("server")
profile = server & vblf & mailbox
address = request.form("address")
'Log on
set newSession = server.CreateObject ("mapi.session")
newSession.logon , , , true, , true, profile
'creates a new message
newMessage = currSession.outbox.messages.add
'set the message properties
newmessage.subject = "Order Form Submission"
newMessage.Text = mailbody
newMessage.Update
set recip = newMessage.recipients.add
recip.name = address
recip.type = CdoTo
recip.resolve
newMessage.update
'send the email
newMessage.send showDialog=false
'log off
newSession.Logoff
Set newSession = nothing
Set newMessage = nothing
Set recip = nothing
'==============================END==================================
I've been trying to figure it out for a while and i just can't see what's
wrong.
Message #2 by <sweber@c...> on Tue, 18 Jul 2000 15:19:05 +0200
|
|
I believe you have a typo here:
newMessage = currSession.outbox.messages.add
correct it should be:
newMessage = newSession.outbox.messages.add
Right?
</Siegfried>
--
Microsoft Most Valuable Professional (MVP) - Exchange Server
Co-author of "Professional CDO Programming", Wrox Press 1999
CDOLive - The Premier Resource for Microsoft Collaboration Data Objects
http://www.cdolive.com
mailto:sweber@c...
This message has been sent to you using Microsoft Exchange Server 2000
Release Candidate 2 (Build 6.0.4368)
> -----Original Message-----
> From: Ben Anderson
> Posted At: Monday, July 17, 2000 10:34 PM
> Posted To: Wrox ASP CDO
> Conversation: [asp_cdo] Can't Send Mail With Exchange Server
> Subject: [asp_cdo] Can't Send Mail With Exchange Server
>
>
> I can't send mail with Exchange Server. I used the code from the
> Proffessional ASP 3.0 book, but i still can't get it to work.
> Here is the
> code that i used:
>
> 'declare the mail variables
> dim
> mailbody,recip,newSession,newMessage,mailbox,server,profile,address
> mailbody =3D width & "<BR>" & height & "<BR>" & color &
> "<BR>" & material
> mailbox =3D request.form("mailbox")
> server =3D request.form("server")
> profile =3D server & vblf & mailbox
> address =3D request.form("address")
>
> 'Log on
> set newSession =3D server.CreateObject ("mapi.session")
> newSession.logon , , , true, , true, profile
>
> 'creates a new message
> newMessage =3D currSession.outbox.messages.add
>
> 'set the message properties
> newmessage.subject =3D "Order Form Submission"
> newMessage.Text =3D mailbody
> newMessage.Update
>
> set recip =3D newMessage.recipients.add
> recip.name =3D address
> recip.type =3D CdoTo
> recip.resolve
> newMessage.update
>
> 'send the email
> newMessage.send showDialog=3Dfalse
>
> 'log off
> newSession.Logoff
>
> Set newSession =3D nothing
> Set newMessage =3D nothing
> Set recip =3D nothing
>
'=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D=3D=3D=3D=3DEND=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>
> I've been trying to figure it out for a while and i just
> can't see what's
> wrong.
>
>
Message #3 by "Kevin W." <Kevin.Worrell@f...> on Wed, 19 Jul 2000 13:55:54
|
|
Below you will find some code I used to do the same. I initially had
problems getting the mail to send because of logon failures. I had to set
the web directory to only allow anonymous access where the account with
permissions was the exchange alias (NT Domain Account). Some of this may
help you out.
'Dim objsession
'Dim objmessage
'Dim objRecips
'Dim strFrom
'Dim strTo
'Dim strSubject
'Dim strMessage
'Dim lngImportance
strFrom=request.form("txtFrom")
strTo=request.form("txtTo")
strSubject = request.form("txtSubject")
strBody=request.form("txtMessage")
'The following four lines of code are just here for test
'purposes to see what variables have been pulled in from the
'HTM form.
Write("strFrom = " & strFrom)
Write("strTo = " & strTo)
Write("strSubject = " & strSubject)
Write("strMessage = " & strBody)
?******Testing Purposes for Authentication*****
Response.Write Request.ServerVariables("LOGON_USER") & "<BR>"
Response.Write Request.ServerVariables("AUTH_USER") & "<BR>"
Set objsession = CreateObject("MAPI.Session")
objsession.logon ,,,,,,"Myserver" & vblf & "MyExchangeAlias"
Set objmessage = objsession.Outbox.Messages.Add
objmessage.subject = "message"
objmessage.Text = "strBody"
Set objRecips = objmessage.Recipients.Add
objRecips.Name = "strTo"
objRecips.Type = 1
objRecips.Resolve
objmessage.Send
objsession.Logoff
Message #4 by "Sergio Davi" <davi@c...> on Wed, 19 Jul 2000 10:48:51 -0300
|
|
This is a multi-part message in MIME format.
------=_NextPart_000_0016_01BFF16E.ECED6260
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Take this... in atacch
send mail using CDONTS
Sergio Davi S Bezera
davi@c...
ICQ: # 75143339
----- Original Message -----
From: Kevin W. <Kevin.Worrell@f...>
To: ASP CDO <asp_cdo@p...>
Sent: Wednesday, July 19, 2000 1:55 PM
Subject: [asp_cdo] Re: Can't Send Mail With Exchange Server
> Below you will find some code I used to do the same. I initially had
> problems getting the mail to send because of logon failures. I had to set
> the web directory to only allow anonymous access where the account with
> permissions was the exchange alias (NT Domain Account). Some of this may
> help you out.
>
>
> 'Dim objsession
> 'Dim objmessage
> 'Dim objRecips
> 'Dim strFrom
> 'Dim strTo
> 'Dim strSubject
> 'Dim strMessage
> 'Dim lngImportance
>
>
> strFrom=request.form("txtFrom")
> strTo=request.form("txtTo")
> strSubject = request.form("txtSubject")
> strBody=request.form("txtMessage")
>
> 'The following four lines of code are just here for test
> 'purposes to see what variables have been pulled in from the
> 'HTM form.
> Write("strFrom = " & strFrom)
> Write("strTo = " & strTo)
> Write("strSubject = " & strSubject)
> Write("strMessage = " & strBody)
>
>
> '******Testing Purposes for Authentication*****
> Response.Write Request.ServerVariables("LOGON_USER") & "<BR>"
> Response.Write Request.ServerVariables("AUTH_USER") & "<BR>"
>
> Set objsession = CreateObject("MAPI.Session")
> objsession.logon ,,,,,,"Myserver" & vblf & "MyExchangeAlias"
> Set objmessage = objsession.Outbox.Messages.Add
> objmessage.subject = "message"
> objmessage.Text = "strBody"
> Set objRecips = objmessage.Recipients.Add
> objRecips.Name = "strTo"
> objRecips.Type = 1
> objRecips.Resolve
> objmessage.Send
> objsession.Logoff
------=_NextPart_000_0016_01BFF16E.ECED6260
Content-Type: text/asp;
name="EnviaMail.asp"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="EnviaMail.asp"
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type"
content=3D"text/html;charset=3Diso-8859-1">
<TITLE>HTML Mail</TITLE>
<%
Sub Write(strWriteThis)
response.write(strWriteThis & "<br>")
end sub
%>
</HEAD>
<BODY>
<%
Dim objMail
Dim Codigo
Dim Nome
Dim EMail
Dim Telefone
Dim myCDONTSMail
Dim strFrom
Dim strTo
Dim strSubject
Dim strMessage
Dim lngImportance
strFrom=3Drequest.form("remetente")
strTo=3Drequest.form("selecionados")
strSubject =3D request.form("Assunto")
strBody=3Drequest.form("Mensagem")
lngImportance =3D request.form("Importancia")
Write("De: =3D " & strFrom)
If Request.Form("Destinatario") =3D "Todos" Then
Set objMail =3D Server.CreateObject("EnviaMail.Enviar")
ObjMail.OpenAlunos
While ObjMail.isEOF =3D False
ObjMail.NextAluno Codigo, Nome, EMail, Telefone
Write("Para =3D " & Trim(Email) & ";")
Write("Assunto =3D " & strSubject)
Write("Mensagem =3D " & strBody)
Write("Prioridade =3D " & lngImportance)
Set myCDONTSMail =3D CreateObject("CDONTS.NewMail")
myCDONTSMail.Send
strFrom,Trim(EMail),strSubject,strBody,lngImportance
Wend
Else
Write("Para =3D " & strTo)
Write("Assunto =3D " & strSubject)
Write("Mensagem =3D " & strBody)
Write("Prioridade =3D " & lngImportance)
Set myCDONTSMail =3D CreateObject("CDONTS.NewMail")
myCDONTSMail.Send strFrom,strTo,strSubject,strBody,lngImportance
End If
=09
Set myCDONTSMail =3D Nothing
Write "Mensagem Enviada com Sucesso"
%> <br>
<input type=3D"button" name=3D"Voltar" value=3D"Voltar"
Onclick=3DJavaScript:history.go(-1)>
</BODY>
</HTML>
Message #5 by "Ben Anderson" <banderson87@h...> on Wed, 19 Jul 2000 17:1:43
|
|
Thanks Kevin, that worked. The problem was with the logon, just like you
said happened to you initially. I had to set the permissions and then
everything worked. Thanks for all the help.
BEN
|
|
 |