Is it possible to allow people to input information and then when the click submit, have the information sent to my email account? If so, how would I go about doing this?
I'm using VB6.

You will need to reference - Microsoft Outlook Object library

Dim Msg As String
  
    Dim objOutlook As Object
    Dim objItem As MailItem
    
    Set objOutlook = CreateObject("Outlook.Application")
    Set objItem = objOutlook.CreateItem(olMailItem)
    
    Msg = "Here is the body text"
    Msg = Msg & vbCrLf
    Msg = Msg & "Over two lines."
    
    With objItem
        .Importance = olImportanceHigh
        .Subject = "Subject Name"
        .To = "me@me.com"
        .CC = "you@you.com"
        .BCC = "another@me.com"
        .Body = Msg
        .Attachments.Add "C:\text.doc"
        
        .Send
    End With
    Set objItem = Nothing
    Set objOutlook = Nothing

pG

Or you get Postie, a free SMTP, POP IMAP client that can send e-mail without Outlook. I have used it myself in various projects and it works flawlessly.

Here is where to get it
http://www.infradig.com/

And here is my send-mail sub

Public Function SendMail(recipient As String, msgbody As String, subject As String, postie As String, smtp_host As String, sender As String) As Boolean
'  This module sends an e-mail to the account(s) asked.
'Parameters:
'  recipient   comma separated list of recipients
'  msgbody     can contain a string with the message body or the filename to attach as message body
'  subject     subject line of message
'  postie      the path to your Postie program
'  smtp_host   the IP address of your SMTP host
'  sender      the e-mail account FROM which to send the e-mail
'
'Returns postie's task ID if successful, zero otherwise
'
   Dim command_line As String
   Dim host_clause As String
   Dim from_clause As String
   Dim to_clause As String
   Dim subject_clause As String
   Dim file_clause As String
   Dim msgbody_clause As String
   Dim exec_return As Integer

   host_clause = " -host:" & smtp_host
   from_clause = " -from:" & sender
   to_clause = " -to:" & recipient
   subject_clause = " -s:" & Chr(34) & subject & Chr(34)
   If FileExists(msgbody) Then
      file_clause = " -file:" & Chr(34) & msgbody & Chr(34)
      command_line = postie & host_clause & to_clause & from_clause & subject_clause & file_clause
   Else
      msgbody_clause = " -msg:" & Chr(34) & msgbody & Chr(34)
      command_line = postie & host_clause & to_clause & from_clause & subject_clause & msgbody_clause
   End If
   exec_return = Shell(command_line, vbHide)
End Function

Public Function FileExists(strFile As String) As Boolean
  Dim intLen As Integer
 
  On Error Resume Next
  intLen = Len(Dir(strFile))
  FileExists = (Not Err And intLen > 0)
End Function

Happy coding

Yomet

Comatose, I am totally for your solution since it will be the best and most portable and will work with no external support.

Now, can you send us the code please.... :)

Ciao

Yomet

This article has been dead for over six months. Start a new discussion instead.