[Outlook 2000 OLE Automation] Paar vraagjes

Pagina: 1
Acties:

  • DPLuS
  • Registratie: April 2000
  • Niet online
Ik heb de volgende code:

Visual Basic 6:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Option Explicit

Private objOutlook As Outlook.Application
Private objMail As Outlook.MailItem

Private Sub Command1_Click()

Dim blnWasStarted As Boolean
blnWasStarted = False

Screen.MousePointer = vbHourglass
Command1.Caption = "Starten outlook..."
DoEvents

On Error Resume Next

Set objOutlook = GetObject(, "Outlook.Application")
If objOutlook Is Nothing Then
    blnWasStarted = True
    Set objOutlook = CreateObject("Outlook.Application")
End If

Set objMail = objOutlook.CreateItem(olMailItem)
objMail.SentOnBehalfOfName = "ik@mezelf.com"
objMail.Recipients.Add(txtEmail).Type = olTo
objMail.Recipients.Add(txtBcc).Type = olBCC
objMail.Subject = "Test E-mail"
objMail.Body = "Dit is een testmailtje!"
objMail.Send
Set objMail = Nothing

If blnWasStarted Then
    objOutlook.Quit
End If

Set objOutlook = Nothing

Command1.Caption = "Verstuurd!"
Screen.MousePointer = vbDefault

End Sub


1: Is er een property in Outlook.Application om 'm visible te maken?
Net zoals in Excel.Application.Visible = True?
Volgens de object browser bestaat deze property namelijk niet.

edit: Na enig zoekwerk ben ik erachter dat dit zou moeten werken via objOutlook.explorers.display...

2: Als Outlook gesloten is voordat ik deze code uitvoer, dan blijft het e-mail bericht in de outbox staan.
Als Outlook van tevoren geopend is, wordt het mailtje DIRECT VERZONDEN!
Kan ik ervoor zorgen dat het mailtje direct verzonden wordt, ook als Outlook initieel gesloten is? (bovendien vind ik dit raar, want op zich open ik outlook toch als ik Set objOutlook = CreateObject("Outlook.Application") doe?)

*update* Volgens een post die ik met google gevonden heb, gaat dit niet.
Enige manier is direct verbinden met SMTP server...

[ Voor 37% gewijzigd door DPLuS op 11-01-2004 21:50 ]