?
Solved

Send Email

Posted on 2003-03-14
9
Medium Priority
?
878 Views
Last Modified: 2013-11-13
How do you use vb to send an email message. I know one way to do it but i dont want anything to pop up (Like the outlook notice).  I want it so the user would not even notice it being sent.  
0
Comment
Question by:allhailcaesar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 18

Accepted Solution

by:
Sethi earned 80 total points
ID: 8142198
The easiest way to send emails or SMS through VB is by using vbSendMail DLL that can be freely downloaded from this site:
http://www.freevbcode.com/ShowCode.Asp?ID=109

However, there is no way you can stop user from noticing it. Although this DLL wont flash a message, but the user will know one way or the other that a mail is being sent.
0
 
LVL 1

Expert Comment

by:GERTJAN
ID: 8142544
You can send e-mail by using the winsock control.
the user would not notice it.
Add the winsock control on a form named sckSMTP
Here is the code to do so



Dim ToAdd As String
Dim CCAdd As String
Dim BCCAdd As String
Dim FromAdd As String
Dim Subject As String
Dim msg As String
Dim SenderDomain As String
Dim intWait As Integer
Dim SignedOut As Boolean
Dim MsgSubject, MsgMessage as string

Function SendMail()
    SMTPAddress = "smtp.domain.com"
    MsgSubject = "subject"
    MsgMessage = "Message"
    frmMain.sckSMTP.Connect SMTPAddress, 25
    Do Until frmMain.sckSMTP.State = sckClosed
        DoEvents
        If frmMain.sckSMTP.State = sckError Then
             Exit Function
        end if
    Loop
End Function

Private Sub sckSMTP_DataArrival(ByVal bytesTotal As Long)
Dim DatRec As String
Dim strBuffer As String
Dim Filenum As Integer
Dim i As Integer
Dim TempPath As String
Dim PrevCommand As String
Dim IsSMTPConnected As Boolean
Dim SMTPAdd As String

SMTPDomain = "domain.com"
'sender E-mailname
EmailUsername = "name@domain.com"
EmailPass = "password"

sckSMTP.GetData DatRec

'For intercepting SMTP data

Select Case Val(Left$(DatRec, 3))

Case 220
 Debug.Print sckSMTP.State
 If Not IsSMTPConnected Then
  IsSMTPConnected = True
  'Notify address
  smtpSendData "HELO <" & SMTPDomain & ">" & vbCrLf 'smtp.
 
 
 End If

Case 250

 Select Case PrevCommand
 
 Case "HELO"
 
 
  'Send the sender address..
  smtpSendData "MAIL FROM: <" & EmailUsername & ">" & _ vbCrLf ' & EmailUsername & Mid$(SMTPAddress, 6) & ">" & _ vbCrLf

 
 Case "MAIL"
    Dim strTo(0 To 50) As String
    Dim TempChar As String
    Dim CountAdress As Integer
    CountAdress = 0
    If InStr(1, EmailTo, ";", vbTextCompare) Then
       For X = 1 To Len(EmailTo)
           TempChar = Mid(EmailTo, X, 1)
           If TempChar = ";" Then
               CountAdress = CountAdress + 1
           Else
               strTo(CountAdress) = strTo(CountAdress) & TempChar
           End If
       Next X
       For Y = 0 To CountAdress
           smtpSendData "RCPT TO: <" & Trim$(strTo(Y)) & ">" & vbCrLf
       Next Y
    Else
     smtpSendData "RCPT TO: <" & Trim$(EmailTo) & ">" & vbCrLf
    End If
 Case "RCPT"

  smtpSendData "DATA" & vbCrLf
 
 Case "VRFY"
 
  IsVerified = True
 
 Case "DATE"
  'Email sent.
 
   
  'CLose the connection
  sckSMTP.Close
  IsSMTPConnected = False
  'Sign Out from Server
 
 End Select
 
Case 251
 
 Select Case PrevCommand
 
 Case "RCPT"
  smtpSendData "DATA" & vbCrLf
 
 
 End Select
 
Case 354

 Select Case PrevCommand
 
  Case "DATA"

   'Server ready for message.Compose the message.
   msg = "DATE: " & Date & vbCrLf & "FROM: " & EmailUsername & vbCrLf & "TO: " & EmailTo & vbCrLf & "SUBJECT: " & MsgSubject & vbCrLf & vbCrLf & MsgMessage & vbCrLf & "." & vbCrLf
 
   smtpSendData msg
 
 End Select
 
 
'Errors
Case Is >= 400
 
 MsgBox Mid$(DatRec, 4), vbInformation, "Error in Email Transaction"
 
 'Close socket
 sckSMTP.Close
 
 If POPAuthorised Then POPAuthorised = False
 IsSMTPConnected = False
 
End Select


End Sub

Private Sub smtpSendData(strMessage As String)

PrevCommand = Left$(Trim$(strMessage), 4)

sckSMTP.SendData strMessage

End Sub

0
 

Author Comment

by:allhailcaesar
ID: 8143516
There is something wrong with this code
It is red

smtpSendData "MAIL FROM: <" & EmailUsername & ">" & _ vbCrLf ' & EmailUsername & Mid$(SMTPAddress, 6) & ">" & _ vbCrLf
0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 

Expert Comment

by:EricOKelly
ID: 8143674
Install IIS on NT/2k/XP (on NT it is in the NT options pack, or in 2k/xp under add/remove programs, windows components)

Include Microsoft CDO in your project references.

then use this for a base;

    Dim mail As New NewMail
   
    mail.From = "someone@somewhere.com"
    mail.To = "someone@somewhere.com"
    mail.Subject = "some subject"
    mail.Body = "some body text"
    mail.Send
0
 
LVL 1

Expert Comment

by:GERTJAN
ID: 8144253
The line must be :

smtpSendData "MAIL FROM: <" & EmailUsername & ">" &  vbCrLf  & EmailUsername & Mid$(SMTPAddress, 6) & ">" &  vbCrLf
0
 

Expert Comment

by:antigovernment
ID: 8310456
i do beleive there is a smtp ocx hing in vb6 under the toolbar components list
0
 

Expert Comment

by:CleanupPing
ID: 9056295
allhailcaesar:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 9699766
Moderator, my recommended disposition is:

    Accept Sethi's comment(s) as an answer.

DanRollins -- EE database cleanup volunteer
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
Suggested Courses

771 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