Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

E-Mail - Confused

Status
Not open for further replies.

ARCITS

Programmer
Apr 4, 2002
99
GB
I need to send an e-mail from VB using a PC's default mail client (Mainly Outlook Express, but also Outlook 97,98,2000)
I am confused with all the posts on the subject.
What is the difference between MAPI and SMTP.
Is there a concise tutorial anywhere and some simple code examples?

Thanks
 
Use the MAPISession and MAPMessage controls.
Here's some sample code

Dim msg As String
MAPISession.UserName = "user"
MAPISession.Password = "password"
MAPISession.SignOn
MAPINotify.SessionID = MAPISession.SessionID
MAPINotify.Compose
MAPINotify.RecipAddress = "blabla@mail.com"
MAPINotify.MsgSubject = "Subject"
MAPINotify.AddressResolveUI = True
MAPINotify.ResolveName
MAPINotify.MsgNoteText = "Hello World"
MAPINotify.AttachmentType = mapData
MAPINotify.AttachmentPathName = "c:\temp\file.txt"
MAPINotify.Send False
MAPISession.SignOff
End Sub

Enjoy
 
Thanks,

Just two quick questions
What is the difference between SMTP and MAPI.
Which is better?
Also with MAPI method how do I stop the little pop up box appearing with message ("Program is attempting to send an e-mail?)

Thanks
 
Well SMTP is a protocol, and MAPI is an application programming interface, that allows you to leverage a messaging library.

Whilst the following isn't the best anology, it may help: consider a web browser and HTTP. The various buttons on your toolbar, and the the fact that you can enter data on pages can be considered to be the interface that allows you to leverage a library of browser functionality. Now the browser library itself uses HTTP (a protocol) to send and receive pages over the web, but that protocol itself does not provide any browser functionality.

MAPI and SMTP have a similar relationship. SMTP is merely a protocol, driven by ASCII prompts and responses over a TCP/IP connection that send mail from one place to another; in itself it provides no real messaging facilities beyond this (it doesn't even pick mail up, it can merely send it). It doesn't have address books, or calendars, or folders, or lists of users, or any of the other features that you might take for granted in Eudora or Outlook/Exchange or Notes, etc.

MAPI, on the other hand, provides an API that does support all these features (and more) - always providing that the underlying messaging system that you are in fact talking to via MAPI supports them , of course.

Which is better? Well, if you want any sort of feature set then I'd say MAPI. If you yuo just want a quick and dirty way of sending a message, then use SMTP (you just need to be able to establish an IP connection on port 25 to a target SMTP server). Here, for example, is an entire SMTP conversation carried out on a telnet client (stuff in bold is responses from the server, and ignore the hyperlinks - tek-tips put those in...):

220 random_smtphost.com SMTP MTA Service Ready
HELO mydomain.com
250 venus.cwb.com
mail from: me@mydomain.com
250 OK
rcpt to: strongm@iamnotsaying.com
250 OK
data
354 Enter Mail, end by a line with only '.'
Here is my mail message
.
250 Message received OK.
quit
221 Goodbye

And you really can't do much more than this in SMTP.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top