Form to Email

Results 1 to 2 of 2

Thread: Form to Email

  1. #1
    Join Date
    Dec 1969

    Default Form to Email

    Hi All,<BR><BR>I was wondering if you could offer me some advice I have a web form which contains a submit button which when pressed put the contents of the fields into an email and sends them to a email address which I have provided, this all works fine, however I need to add to this either have a field that a email address can be entered and put this address in the CC section of the email on submit or preferably look up the mailing list for a name entered in a field and add this to the CC section of the email. I am really new to this so any pointers or help would be very much appreciated.<BR>Rgds<BR><BR>Nora.

  2. #2
    Join Date
    Dec 1969

    Default RE: Form to Email

    Try this for sending emails:<BR><BR>Theres no CC option (if you&#039;re desperate for one, I could write it in), but you can pass the SentTo argument a semi-colon delimeted email addresses:<BR><BR>";you@yourplace. net"<BR><BR>This function returns any errors encountered so that you can (if you want to) display it back to the user.<BR><BR>Function SendEmail(SendTo, SendFrom, Subject, Message, Format, Importance)<BR>&#039;SendTo and SendFrom must be valid email addresses.<BR>&#039;The format is either 0 (regular) or 1 (HTML)<BR>&#039;Importance is 0 (low), 1 (regular), or 2 (high)<BR><BR>If Not IsValidEmail(SendTo) Then<BR>SendEmail = "The TO address is not valid"<BR>Exit Function<BR>End If<BR><BR>If Not IsValidEmail(SendFrom) Then<BR>SendEmail = "The FROM address is not valid"<BR>Exit Function<BR>End If<BR><BR>If Len(Subject) &#060; 1 Then<BR>SendEmail = "A subject line was not provided"<BR>Exit Function<BR>End If<BR><BR>If Len(Message) &#060; 1 Then<BR>SendEmail = "A message line was not provided"<BR>Exit Function<BR>End If<BR><BR>If Len(Format) &#060; 1 Then<BR>Format = 0<BR>Else<BR>If Format &#060;&#062; "0" And Format &#060;&#062; "1" Then<BR>SendEmail = "An incorrect format was specified" & " " & Format<BR>Exit Function<BR>End If<BR>End If<BR><BR>If Len(Importance) &#060; 1 Then<BR>Importance = 1<BR>Else<BR>If Importance &#060;&#062; 0 And Importance &#060;&#062; 1 And Importance &#060;&#062; 2 Then<BR>SendEmail = "An incorrect importance was specified"<BR>Exit Function<BR>End If<BR>End If<BR><BR>Dim objMail<BR>Set objMail = Server.CreateObject("CDONTS.NewMail")<BR><BR>objMa il.From = SendFrom<BR>objMail.Subject = Subject<BR><BR>&#039;you need TO add these lines FOR the mail<BR>&#039;to be sent in HTML format<BR>objMail.BodyFormat = Format<BR>objMail.MailFormat = Format<BR><BR>objMail.To = SendTo<BR>objMail.Bcc = ""<BR>objMail.Body = Message<BR>objMail.Send<BR><BR>set objMail = nothing<BR>SendEmail = ""<BR>End Function<BR><BR>Function IsValidEmail(EmailAddy)<BR>Dim goby<BR>goby = 0<BR><BR>&#039;if the len is less than 5 then it can&#039;t be an email<BR>&#039;(i.e.: a@a.c)<BR>If Len(EmailAddy) &#060;= 5 Then<BR>goby = 1<BR>End If<BR><BR>If InStr(1, EmailAddy, "@", 1) &#060; 2 Then<BR>&#039;If we find one and only one @, then the<BR>&#039;email address is good to go.<BR>goby = 1<BR>Else<BR>If InStr(1,EmailAddy, ".", 1) &#060; 4 Then<BR>&#039;Must have a &#039;.&#039; too<BR>goby = 1<BR>End If<BR>End If<BR><BR>If goby &#060;&#062; 0 then<BR>&#039;Well , if goby &#060;&#062; 0 then something<BR>&#039;must be wrong<BR>IsValidEmail = False<BR>Else<BR>IsValidEmail = True<BR>End If<BR>End Function<BR><BR><BR>Good luck!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts