Solved

Sending email via an smtp gateway server with actionscript

Posted on 2006-07-18
7
1,302 Views
Last Modified: 2012-06-22
I know how to call an asp page with values, but what would the asp code parameters need to look like to send an email using an smtp gateway server?
0
Comment
Question by:cbittner
  • 3
  • 3
7 Comments
 
LVL 17

Accepted Solution

by:
Dushan911 earned 500 total points
ID: 17135340
0
 
LVL 2

Expert Comment

by:Rawdon Hume
ID: 17137317
This is for using asp.net which is the similar to asp only better, if you haven't already tried sp.net then do it's a lot better and easer to code: download and install Microsoft Visual Web Developer 2005 Express Edition free from: http://msdn.microsoft.com/vstudio/express/vwd/download/ it's got code prompting and is dead easy to use ;0)

You can use a defualt smtp gateway like so:

 'Create an instance of the MailMessage class
  Dim objMM as New MailMessage()

  'Set the properties - send the email to the person who filled out the
  'feedback form.
  objMM.To = "webmaster@yoursite.com"
  objMM.From = txtEmail.Text

  'If you want to CC this email to someone else, uncomment the line below
  'objMM.Cc = "someone@someaddress.com"

  'If you want to BCC this email to someone else, uncomment the line below
  'objMM.Bcc = "someone@someaddress.com"

  'Send the email in text format
  objMM.BodyFormat = MailFormat.Text
  '(to send HTML format, change MailFormat.Text to MailFormat.Html)

  'Set the priority - options are High, Low, and Normal
  objMM.Priority = MailPriority.Normal

  'Set the subject
  objMM.Subject = "4GuysFromRolla.com - Feedback"

  'Set the body
  objMM.Body = "At " + DateTime.Now + " feedback was sent from an ASP.NET " & _
               "Web page.  Below you will find the feedback message " & _
               "send by " & txtName.Text & "." & vbCrLf & vbCrLf & _
               "---------------------------------------" & vbCrLf & vbCrLf & _
               txtMessage.Text & vbCrLf

 
  'Specify to use the default Smtp Server
  SmtpMail.SmtpServer = ""
 
  'Now, to send the message, use the Send method of the SmtpMail class
  SmtpMail.Send(objMM)

See: http://www.4guysfromrolla.com/webtech/080801-1.shtml

If your using .net version 2 you have to update the code to:

       'Create an instance of the MailMessage class
        Dim objMM As New System.Net.Mail.MailMessage
       
        ' Get the reply address from the web page form
        Dim ad As New System.Net.Mail.MailAddress("No@Reply.com")
       
        ' Set the a varible to be used in defining the SmtpClient
        Dim SmtpMail As New System.Net.Mail.SmtpClient()
       
       'This object stores the authentication values
        Dim basicAuthenticationInfo As New System.Net.NetworkCredential()
       
       'Put your own, or your ISPs, mail server name onthis next line
        SmtpMail.Host = "localhost"
 
        SmtpMail.Credentials = basicAuthenticationInfo
       
        ' Set the properties - send the email to me
        objMM.To.Add("me@hotmail.com")
       
        ' Set the reply addess to the e-mail address of who ever filled out the form
        objMM.From = ad

        ' Send the email in text format
        objMM.IsBodyHtml = False

        ' Set the priority - options are High, Low, and Normal
        objMM.Priority = System.Net.Mail.MailPriority.Normal

        ' Set the subject
        objMM.Subject = "4GuysFromRolla.com - Feedback"

        ' Set the body ...BNo idea if the body part is ok as not sure what this vbCrLf ment to do quite
        objMM.Body = "At " + DateTime.Now + " feedback was sent from an ASP.NET " & _
               "Web page.  Below you will find the feedback message " & vbCrLf & vbCrLf & _
               "---------------------------------------" & vbCrLf & vbCrLf & _
              FeedBackTxtBox.Text & vbCrLf
 
        ' Specify to use the default Smtp Server
       SmtpMail.Host = "localhost"

        ' Now, to send the message
        SmtpMail.Send(objMM)

Hope that’s helps....do you mind me asking how you are passing values to your asp page? I found it to be a pain with flash so be interested in knowing your method ?
0
 

Author Comment

by:cbittner
ID: 17141369
rabidlemming - I am using the following Flash format to POST my variables:
loadVariables("sendEmail.aspx", _level0.loginVars_mc, "POST");
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Expert Comment

by:Rawdon Hume
ID: 17142543
how are you catching the variables with the aspx page are using Request.Form("") code to pass the values, lol your asking the question and here I am asking you a question ...did my help in the post above prove any useful to you?

I always used Request.QueryString("") to pass values through the url but been plagued with issues as doesn’t support a lot of symbols or characters so that’s why I’m interested in your method lol
0
 

Author Comment

by:cbittner
ID: 17145573
Hey that is what makes for a fun dynamic exchange. Yes I am using the below, I write it out to confirm the values. Not that I use getURL in Flash when I use the following so I can see the output, once I am convinced the aspx page is working I go back to using the loadVariables function.

<% response.Write("email Addy: " + request.Form("emailaddy") + "   more info: " + request.Form("moreinfo") ) %>
0
 
LVL 2

Expert Comment

by:Rawdon Hume
ID: 17147217
yer i spent many waited hours trying to pass values through the url only to find it wasn't all that reliable, I then discovered the advantages to using .sendAndLoad action script lol see here:

http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/ASP_DOT_NET/Q_21924273.html

Really you or Dushan911  should have the points from that link as it was his link and this post that lead me to http://www.kirupa.com/developer/actionscript/forms_database.htm and gave me the idea of using Request.Form("") over Request.QueryString("")

so thanks for your help....btw how did you get on with your problem lol ?
0
 

Author Comment

by:cbittner
ID: 17333595
I ended up using the sendAndLoad, all is good thanks for everyones help.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now