Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > send outlook message


Reply
 
Thread Tools Display Modes
  #1  
Old 09-13-2000, 10:08 PM
mojo
Guest
 
Posts: n/a
Question send outlook message


I have the following code which creates an email message using outlook:

Private Sub CBBen_Click()
Dim aplOutlook As Outlook.Application
Dim MailMessage As MailItem
Dim CName As String
Dim JNumber As Integer
CName = FrmMail.TBCName.Text
JNumber = FrmMail.TBJobnumber.Text

Set aplOutlook = CreateObject("Outlook.Application")
Set MailMessage = aplOutlook.CreateItem(olMailItem)

With MailMessage
.To = "bav"
.Subject = "JobTracker Notice: Job Complete"
.Body = "Job number " & JNumber & " for " & CName & " has been completed."
.Send
End With

MsgBox "Message Sent"

Set MailMessage = Nothing
Set aplOutlook = Nothing

End Sub

It works fine except that it only puts the message in the outlook Outbox. Is there another piece of code I have to use in order to actually send the message?

ps I have referenced MS Outlook 9.0 Object Library

Thanks

mojo

Reply With Quote
  #2  
Old 09-14-2000, 06:00 AM
whelanp
Guest
 
Posts: n/a
Default Re: send outlook message

I use the following code which works fine,

The main differences seem to be my initial setup of the email and the recipient settings.

Public Sub DoEmail(byval strMailAddr As String)

On Error GoTo ProcErr

Dim olApp As Outlook.Application
Dim olSpace As Outlook.NameSpace
Dim olTopFld As Outlook.MAPIFolder ' Object representing top most folder we're looking in
Dim olFldOut As Outlook.MAPIFolder '
Dim olMail As Outlook.MailItem '

Set olApp = New Outlook.Application
Set olSpace = olApp.GetNamespace("MAPI")

Set olTopFld = olSpace.Folders("Mailbox - Application Server")
Set olFldOut = olTopFld.Folders("Outbox")

Set olMail = olFldOut.Items.Add(olMailItem)

With olMail

With .Recipients
.Add strMailAddr
.ResolveAll
End With

.Subject = "Subject"
.Body = "Body"
.Importance = olImportanceHigh
.Send
End With


ProcExit:
Exit Sub

ProcErr:
MsgBox "Error: " & Err.Description
Resume ProcExit
End Sub


Hope this helps.
Reply With Quote
  #3  
Old 09-14-2000, 09:46 AM
Dazz
Guest
 
Posts: n/a
Smile Re: send outlook message

I just logged on to pose a question about automatically sending an e:mail through outlook.

Don't you just love this place.

Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->