• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 364
  • Last Modified:

send email via VB.NET using PHP as the mail processor ?

Hi, i hope u guys would understand what i'm sayin cuz im not sure that i do!
here is what i think i need to do:
i got a very simple PHP mail sender which i want to use with VB.NET (If possible in any way), VB would submit a couple of text fields to the PHP mailer which contains the email that would recieve the email...

If that is not possible, is there any other way i can send mail from VB.NET without having to use SMTP servers...

sorry if i'm not clear enough..

Thank you.
0
nkrulez
Asked:
nkrulez
  • 4
  • 3
1 Solution
 
BTosonCommented:
Hi,

I'm assuming you have a PHP script hosted somewhere which will you want to call through your VB.NET programme?
If so then why not just use a HTTP POST request?
0
 
nkrulezAuthor Commented:
yah that is pretty much it, but i'm a total newbie to VB.NET
could somebody plz tell me how 2 use HTTP POST request ?
0
 
BTosonCommented:
Simplest way is something like this.  Please don't forget to check your values before submitting them!
Dim POSTVariables = New NameValueCollection
POSTVariables.Add("email", email)
POSTVariables.Add("name", name)
Dim Request As New WebClient
Dim Result = Text.Encoding.UTF8.GetString(Request.UploadValues("http://url/to/mailer.php", POSTVariables))

Open in new window

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
BTosonCommented:
Oh and don't forget to put a Imports System.Net in your code behind!
0
 
nkrulezAuthor Commented:
But this way my clients will have to have framework installed in order for the application to work, right ?

I'm not a fan of framework .. is there any other possible way to accomplish this without having to use framework ?

thanks alot.
0
 
nkrulezAuthor Commented:
oh and,

Error1   Type 'NameValueCollection' is not defined.
Error2   Name 'email' is not declared.
Error3   'Encoding' is not a member of 'String'.

0
 
BTosonCommented:
Well as you are using VB.NET, anythign you deploy will require the relevant version of the .NET framework to be installed.

See below for namespaced/clarified code.
Dim POSTVariables = New System.Collections.Specialized.NameValueCollection
POSTVariables.Add("email", "e-mailaddresshere")
POSTVariables.Add("name", "name or whatever here")
Dim Request As New WebClient
Dim Result = System.Text.Encoding.UTF8.GetString(Request.UploadValues("http://url/to/mailer.php", POSTVariables))

Open in new window

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now