Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: AW: Re: Sending email


Message #1 by "Neethling, Dirk BYNI/PLM" <Dirk.Neethling2@h...> on Sat, 26 Aug 2000 20:37:41 +0200
i'm dirk, but i found your code below useful anyway, thanks!



> -----Urspr=FCngliche Nachricht-----

> Von:	Ray Murphy [SMTP:raymondmurphy@c...]

> Gesendet am:	Saturday, August 26, 2000 3:52 PM

> An:	ASP Databases

> Betreff:	[asp_databases] Re: Sending email

>

> Nick,

>

> There are probably a number of ways to send mail, so I think you'll 

be

> getting a variety of replies to this one.

>

> Here is one method that I have been using with no problems so far :

>

>  <%

>     Dim strHTML

>     strHTML =3D "<HTML>"

>     strHTML =3D strHTML & "<HEAD>"

>     strHTML =3D strHTML & "<TITLE>Order Completion</TITLE>"

>     strHTML =3D strHTML & "</HEAD>"

>     strHTML =3D strHTML & "<BODY>"

>     strHTML =3D strHTML & "<P>Order Placed at <STRONG>" & Time & 

"</STRONG>"

>     strHTML =3D strHTML & "</BODY>"

>     strHTML =3D strHTML & "</HTML>"

>        

>     set NewMail =3D Server.CreateObject("CDONTS.NewMail")

>     NewMail.From =3D "customer@c..."

>     NewMail.To   =3D "billy@b..."

>     NewMail.CC =3D "bobby@b..."

>     NewMail.BCC =3D "benny@b..."

>     NewMail.BodyFormat =3D CdoBodyFormatHTML

>     NewMail.Body =3D strHTML

>    

>     NewMail.Subject =3D "Customer Placed An Order"

>       

>     NewMail.Send

>     Set NewMail =3D Nothing

>  %>

>

> Hope this is of some use.

>

>

> Ray

>

> ---

> You are currently subscribed to asp_databases


> $subst('Email.Unsub')

Message #2 by "Andi Gladwin" <illusionist@l...> on Sat, 26 Aug 2000 21:20:10 +0100
Hi!



I'm new here (just signed up a few minutes ago) and thought I send this

little email as an introduction.  I'm a 17 year old programmer (HTML,

JavaScript, ASP, Visual Basic, SQL, DHTML, VBScript etc) from the UK and

look forward to joining in here.



Here's an addition to Ray's CDONTS code... although it's a very minor change

it will make the script much more practical in the real world.  Here goes:



<%



' 1st Addition - add variables for the title, sender, carbon copy and blind

carbon copy



	Dim strFrom, strTo, strCC, strBCC, strTitle



	strFrom = "admin@a..."

	strTo = Request.Form("useremail")

	strCC = Request.Form("carboncopy")

	strBCC = Request.Form("blindcarboncopy")

	strTitle = "This is my title"



	Dim strHTML

	strHTML = "<HTML>"

	strHTML = strHTML & "<HEAD>"

	strHTML = strHTML & "<TITLE>Order Completion</TITLE>"

	strHTML = strHTML & "</HEAD>"

	strHTML = strHTML & "<BODY>"

	strHTML = strHTML & "<P>Order Placed at <STRONG>" & Time & "</STRONG>"

	strHTML = strHTML & "</BODY>"

	strHTML = strHTML & "</HTML>"



'Change 2 - now use the variables



	set NewMail = Server.CreateObject("CDONTS.NewMail")

	NewMail.From = strFrom

	NewMail.To   = strTo

	NewMail.CC = strCC

	NewMail.BCC = strBCC

	NewMail.BodyFormat = CdoBodyFormatHTML

	NewMail.Body = strHTML

	NewMail.Subject = strTitle



	NewMail.Send

	Set NewMail = Nothing

%>



I know it's a small change but will help when you are making applications

where mail needs to be sent to different people, will different titles etc.



You could also add If statements to see if certain parts of the code are

needed (namely BCC and CC).  CDONTS is a great piece of work... there is so

much you can do with it, this is just the tip of the icedberg, as they say.



Seeya



Andi



Message #3 by "Neethling, Dirk BYNI/PLM" <Dirk.Neethling2@h...> on Sat, 26 Aug 2000 22:48:31 +0200
i used the following code in an .asp file which gets called on 

completion of

a dataset submitChanges(). However i keep getting the following error:

error:

Active Messaging error '000004f9'

Der Informationsspeicher steht zur Zeit nicht zur Verf=FCgung. [MAPI 

1.0 -

[MAPI_E_LOGON_FAILED(80040111)]]

/bautagesberichte/forms/confirmByMail.asp, line 49



code:



<%@ Language=3DVBScript %>

<HTML>

<HEAD>

</HEAD>

<BODY>

<%

On Error Resume Next

dim From

From =3D "dirk.neethling2@h..."

dim bstrServer

bstrServer =3D "BYHNS052"



Dim objSession, bstrProfileInfo

bstrProfileInfo =3D bstrServer & chr(10) & 

"dirk.neethling2@h..."



Set objOMSession =3D Server.CreateObject("MAPI.Session")

objOMSession.Logon "", "", False, True, 0, True, bstrProfileInfo



If Err.Number <> 0 Then

   Response.Write("Unable to connect to Mail Server! <BR>")

   Response.Write("Error source: " & Err.Source & "<BR>")

   Response.Write("Error number: " & Err.Number & "<BR>")

   Response.Write("Error description: " & Err.Description & "<BR>")

   Err.Clear

Else

      

    Dim strHTML

    strHTML =3D "<HTML>"

    strHTML =3D strHTML & "<HEAD>"

    strHTML =3D strHTML & "<TITLE>Bautagesbericht Completion</TITLE>"

    strHTML =3D strHTML & "</HEAD>"

    strHTML =3D strHTML & "<BODY>"

    strHTML =3D strHTML & "<P>Bautagesbericht completed at <STRONG>" & 

Time &

"</STRONG>"

    strHTML =3D strHTML & "<P>by username:<STRONG>" & 

Session.Contents("usr")

& "</STRONG>"

    strHTML =3D strHTML & "</BODY>"

    strHTML =3D strHTML & "</HTML>"

       

    Set objmessage =3D objOMSession.Outbox.Messages.Add



    objmessage.Subject=3DSubject

    objmessage.Text=3DBody



    Set objonerecip =3D objmessage.Recipients.Add

    objonerecip.Name =3D "dirk.neethling2@h..."

    objonerecip.Resolve



    objmessage.Send

   Set objmessage =3D Nothing



End if



Response.Redirect "Bautagesberichte_30X.asp"

%>

</body>

</HTML>





the mail-client is Outlook in an NT environ, the outlook 

authentication=3DNT

could you please tell me what's the matter with my code?

dirk



> -----Urspr=FCngliche Nachricht-----

> Von:	Ray Murphy [SMTP:raymondmurphy@c...]

> Gesendet am:	Saturday, August 26, 2000 3:52 PM

> An:	ASP Databases

> Betreff:	[asp_databases] Re: Sending email

>

> Nick,

>

> There are probably a number of ways to send mail, so I think you'll 

be

> getting a variety of replies to this one.

>

> Here is one method that I have been using with no problems so far :

>

>  <%

>     Dim strHTML

>     strHTML =3D "<HTML>"

>     strHTML =3D strHTML & "<HEAD>"

>     strHTML =3D strHTML & "<TITLE>Order Completion</TITLE>"

>     strHTML =3D strHTML & "</HEAD>"

>     strHTML =3D strHTML & "<BODY>"

>     strHTML =3D strHTML & "<P>Order Placed at <STRONG>" & Time & 

"</STRONG>"

>     strHTML =3D strHTML & "</BODY>"

>     strHTML =3D strHTML & "</HTML>"

>        

>     set NewMail =3D Server.CreateObject("CDONTS.NewMail")

>     NewMail.From =3D "customer@c..."

>     NewMail.To   =3D "billy@b..."

>     NewMail.CC =3D "bobby@b..."

>     NewMail.BCC =3D "benny@b..."

>     NewMail.BodyFormat =3D CdoBodyFormatHTML

>     NewMail.Body =3D strHTML

>    

>     NewMail.Subject =3D "Customer Placed An Order"

>       

>     NewMail.Send

>     Set NewMail =3D Nothing

>  %>

>

> Hope this is of some use.

>

>

> Ray

>

> ---

> You are currently subscribed to asp_databases


> $subst('Email.Unsub')


  Return to Index