Toon posts:

[VBA] E-mail versturen met Lotus Notes in Access?

Pagina: 1
Acties:
  • 279 views sinds 30-01-2008
  • Reageer

Verwijderd

Topicstarter
Ik heb hier een behoorlijk grote Access applicatie, en nu is het de bedoeling dat deze bij bepaalde akties een e-mailtje verzend. Ik heb het geprobeerd met bijv:

code:
1
DoCmd.SendObject acSendReport, "Klanten Op Stop", acFormatRTF, "blaat@blaat.nl", , , "Sending A Report", "This is the Access Report"


Echter komt Access continue met een pop-up waarin je een Outlook Express profiel moet selecteren om te verzenden. Op deze pc's wordt Outlook echter niet gebruikt, maar Lotus Notes.

Hoe kan ik in VBA (Access) een e-mail verzenden met enkel Lotus Notes tot mijn beschikking?

Bedankt!

  • OZ-Gump
  • Registratie: November 2002
  • Laatst online: 14-05-2024

OZ-Gump

terug van weggeweest

Als het een 'behoorlijk grote' Access applicatie is, is het misschien verstandig om ervoor te zorgen dat je applicatie kan mailen met elke mailclient die er is, in plaats van enkel met Lotus Notes.

Er zijn verschillende opties: er zijn componenten beschikbaar welke je in je applicatie kunt gebruiken om te mailen, zodat je altijd e-mail kunt sturen, onafhankelijk van de mailclient.
Ook kun je zelf in bijvoorbeeld Delphi een DLL bouwen waarmee je kunt mailen, gebruik makend van bijvoorbeeld de Indy clients. Hiermee bouw je eigenlijk het component uit het vorige punt, maar dan maak je hem zelf ;)

My personal website


  • Danfoss
  • Registratie: Mei 2000
  • Laatst online: 25-05 21:40

Danfoss

Deze ruimte is te koop..

OZ-Gump schreef op 11 mei 2004 @ 08:59:
Als het een 'behoorlijk grote' Access applicatie is, is het misschien verstandig om ervoor te zorgen dat je applicatie kan mailen met elke mailclient die er is, in plaats van enkel met Lotus Notes.
Klopt.

Mocht je toch alleen Lotus Notes clients willen ondersteunen heb je hier een voorbeeld die ik een keer gevonden heb
Visual Basic:
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
'If you want to send a message to more than one person or copy or blind carbon copy the following may be of use to you.
'
'MailDoc.sendto = Recipient
'MailDoc.CopyTo = ccRecipient
'MailDoc.BlindCopyTo = bccRecipient
'
'
'Also for multiple email addresses you just set MailDoc.sendto to an array of variants each of which will receive the message. So
'
'Dim recip(25) as variant
'
'recip(0) = "emailaddress1"
'recip(1) = "emailaddress2" e.t.c
'
'maildoc.sendto = recip
'


Sub SendNotesMail(Subject As String, Attachment As String, Recipient As String, BodyText As String)
'Set up the objects required for Automation into lotus notes
    Dim Maildb As Object 'The mail database
    Dim UserName As String 'The current users notes name
    Dim MailDbName As String 'THe current users notes mail database name
    Dim MailDoc As Object 'The mail document itself
    Dim AttachME As Object 'The attachment richtextfile object
    Dim Session As Object 'The notes session
    Dim EmbedObj As Object 'The embedded object (Attachment)
    'Start a session to notes
    Set Session = CreateObject("Notes.NotesSession")
    'Get the sessions username and then calculate the mail file name
    'You may or may not need this as for MailDBname with some systems you
    'can pass an empty string
    UserName = Session.UserName
    MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
    'Open the mail database in notes
    Set Maildb = Session.GETDATABASE("", MailDbName)
     If Maildb.ISOPEN = True Then
          'Already open for mail
     Else
         Maildb.OPENMAIL
     End If
    'Set up the new mail document
    Set MailDoc = Maildb.CREATEDOCUMENT
    MailDoc.Form = "Memo"
    MailDoc.sendto = Recipient
    MailDoc.Subject = Subject
    MailDoc.Body = BodyText
    MailDoc.SAVEMESSAGEONSEND = "False"
    'Set up the embedded object and attachment and attach it
    If Attachment <> "" Then
        Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
        Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment")
    End If
    'Send the document
    MailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items folder
    MailDoc.SEND 0, Recipient
    'Clean Up
    Set Maildb = Nothing
    Set MailDoc = Nothing
    Set AttachME = Nothing
    Set Session = Nothing
    Set EmbedObj = Nothing
End Sub


Sub main()

Call SendNotesMail("Subject, "c:\attachment.txt", "user@domain.com", "test mail")

End Sub

Sys Specs