Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sending mail programmatically
Message
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01434904
Message ID:
01435516
Views:
70
Sure!

This is a super-simple app I created with vb.net. Create a new console app and put the following code in Module1.vb, and add a reference to system.web or system.web.mail (don't remember which, but it's easy enough to try). The code should be self-explanatory.

It takes a couple of command-line arguments: addressee and smtp server (optional).
Imports System.Web.Mail

Module Module1

    Sub Main(ByVal cmdargs() As String)

        Dim message As New System.Web.Mail.MailMessage, _
            server As String, _
            SendTo As String

        SendTo = cmdargs(0)

        If cmdargs.Length() = 2 Then
            server = cmdargs(1)
        Else
            server = ""
        End If


        Try
            message.To = SendTo
            message.From = "test@memeME.com"
            message.Subject = "Test message sent on " + Now().ToString()
            message.Body = "Test email"
            If server <> "" Then
                SmtpMail.SmtpServer = server
            End If
            SmtpMail.Send(message)
        Catch ex As Exception
            Console.WriteLine("Something didn't work")
            Console.WriteLine(ex)
        End Try


    End Sub

End Module
>Hey Alex, I prefer to keep my hand clean:) if necessary I can install the .net library on those PC..though i do't know how to manage .net environmnt...but if you have something to let me see...i could try ;)
>See you ....
>Alessio
>
>>Ciao Alessio,
>>
>>Winsock? Man, you like to get your hands dirty, don't you?
>>
>>I have used blat in the past (a very long time ago) and it was fine for what I needed.
>>
>>Also, if the target computers have the .net library installed, it'd take you all of about half a dozen lines of code to write a console app that sends emails.
>>
>>I imagine you know this already, but outlook has a com interface and I think Eudora does so too.
>>
>>Ci vediamo...
>>
>>Alex
>>
>>
>>>Hi all,
>>>I have to send mail programmatically from a PC. I was thinking to use the winsock.ocx activex to do that but i Have a doubt. What if the PC is under a Proxy ? Should I set the winsock to exit ? ad if so, How ?
>>>Of course I could use also other way but i prefer not to use outlook.
>>>Any ideas ?
>>>
>>>Thank u all
>>>alessio
Low-carb diet not working? Try the Low-food diet instead!
Previous
Reply
Map
View

Click here to load this message in the networking platform