?
Solved

Example - Sending email in Vb app

Posted on 1998-12-30
3
Medium Priority
?
162 Views
Last Modified: 2010-05-03
I would like to see an example of sending a simple email msg from within VB - but, I don't want to use the MAPI control.
0
Comment
Question by:edved
[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
  • 2
3 Comments
 
LVL 13

Accepted Solution

by:
Mirkwood earned 150 total points
ID: 1453240
Here is an example of using OLE Messaging to send a message:

Dim oSession As Object
 
Set oSession = CreateObject("MAPI.Session")
oSession.Logon "MS Exchange Settings", True
Dim objMessage As Object ' Message object
Dim objOneRecip As Object ' Recipient object
 
If oSession Is Nothing Then
MsgBox "You have to log on first...."
Exit Sub
End If
 
Set objMessage = oSession.Outbox.Messages.Add
' create the recipient
Set objOneRecip = objMessage.Recipients.Add
objOneRecip.Name = "Rickcau@Microsoft.com"
objOneRecip.Type = mapiTo
objOneRecip.Resolve (True) 'Show dialog to resolve ambiguities
With objMessage ' message object
subject = "Test MAPI/OLE VB Message w/ole object - explicit"
Text = "Like you really wanted this ... please delete this test"
End With
' send the message
objMessage.Send showDialog:=False

For more information on direct MAPI calls and OLE Messaging, in the MSDN Library, see the book Win32 Messaging API (MAPI) in the Win32 SDK.

VB4: VBMAIL.ZIP MAPI sample to send/retrieve mail (VB4) at http://www.geocities.com/~scvb/allfiles.htm
0
 

Author Comment

by:edved
ID: 1453241
Mirkwood,Thanks for the reply.

Question: Are the "subject" and "text" objects string variables? How can I set the "text" object to point to a text file?
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1453242
DO you mean "add an attachment" or you want to use a file as source for your email.

I think you mean the second and in that case I have to disappoint you. You just have to read the file and copy it to the text property.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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