Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

sending email from VB application

Posted on 2001-06-25
5
Medium Priority
?
191 Views
Last Modified: 2013-11-13
I need to send email from my VB application. How do I do it? My application runs in DOS prompt and accepts command line arguments. Should I use MAPI or Winsock object?

0
Comment
Question by:sramaswa
[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
5 Comments
 
LVL 28

Expert Comment

by:iboutchkine
ID: 6225160
MAPI e-mail
'make sure that on the default e-mail use of MAPI server is allowed

Option Explicit
'2 controls Microsoft MAPI Control 6.0 -> MAPISession and MAPIMessages

Private Sub Command1_Click()
  Dim msg As String
 
  Screen.MousePointer = vbHourglass
 
  msg = "This is a test email"
 
  With Me

    .MAPILogOn.SignOn ' use current user
 
    Do While .MAPILogOn.SessionID = 0
      DoEvents ' need to wait until the new session is created
    Loop
   
   Call SendToEmail("iboutchkine@hotmail.com", msg)
   
    .MAPILogOn.SignOff
  End With
 
  Screen.MousePointer = vbNormal
 
End Sub

Private Sub SendToEmail(ByVal Email As String, ByVal msg As String)
  With MAPIMessages1
    'create a new message and address it
    .SessionID = MAPILogOn.SessionID
    .Compose
    .RecipDisplayName = Email
    .AddressResolveUI = True
    .RecipAddress = "smtp:" & Email
   
    .MsgSubject = "VB GENERATED E-MAIL"
'attachment
'    .AttachmentPathName = "c:\a\a.htm"
    .MsgNoteText = msg
    .Send False
  End With
End Sub

0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6225572
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Const SW_NORMAL = 1

sURL = "mailto:ChuckyCheese@PP.com"

ShellExecute hwnd, "open", sURL, vbNullString, vbNullString, SW_NORMAL
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 150 total points
ID: 6225675
You better use this free tool: http://www.freevbcode.com/ShowCode.Asp?ID=109
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 6225923
0
 
LVL 6

Expert Comment

by:kahlean
ID: 6225957
http://www.siteexperts.com/tips/backend/ts12/page1.asp

If you have win2000 running, you can use this sample code as well. THis will uses cdonts to send email. The concept behid this is by creating a vb script file which contains the the database connectivity, the email content as well. T oinvoke this vbs file just at your dos prompt and type cscript email.vbs

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

688 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