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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to send an email using exchange server?

Status
Not open for further replies.

essnrv

Programmer
Jun 27, 2002
229
0
0
IN
Hi,

I am trying to write a simple routine to send an email using exchange server. I saw couple of postings here, but none of it is clear.
Do I need to download any Dlls or need install anything ? Please advice me in right direction. if anybody have any VB code is for this scenario, really that will be very helpful to me.

Thanks in advance


 
You will have to take out my Var's but this code works for me.

Also make sure you have MAPImessage and MAPISession control on the form. Also i am not sure if you need a reference to OutLook set in your project. I have Outlook 9 as a reference in mine.

CODE:
MAPISess.LogonUI = True
MAPISess.DownLoadMail = False
MAPISess.SignOn
MAPIMess.SessionID = MAPISess.SessionID
MAPIMess.Compose
MAPIMess.AddressResolveUI = True

MAPIMess.Compose
MAPIMess.MsgSubject = "Job# " & JobID & " Quality Data"

'The value 1 is passed to the Space() function in the
'next line because there is one attachment to add
'This space acts as a placeholder for the attachment

MAPIMess.MsgNoteText = Space(1) & vbCrLf & "Quality Data Attachment"
MAPIMess.AttachmentPathName = (ReportPath & JobID & ".xls")


MAPIMess.MsgReceiptRequested = True

MAPIMess.Send True

With MAPISess
.SignOff ' Close the session.
.NewSession = False ' Flag for new session.
.NewSession = .NewSession ' Reset flag.
End With

Msg = "There has been a 'Read' Receipt attached" _
& Chr$(13) & "to your message for your convenience" _
& Chr$(13) & "you will be notified when the message is read"
Style = vbOKOnly + vbInformation
Title = "Email Request"
Response = MsgBox(Msg, Style, Title)
 
Hi,
I tried this code but got an error message "Error 91..."
Shouldn't be there something like:

Set MAPISess = New ...?
 
I do not have that code in my program, you may need it depending on your code, do you have the MAPI controls on the form?
Do you have Outlook as a reference in your project?
 
For the above code you would not need Outlook references, just add the MAPI controls to the form.

But if you can assume that the machine you are running on has Outlook you can do it a lot easier using them.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top