If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > sending trigger email in excel

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-03-05, 11:14
fullymooned fullymooned is offline
Registered User
 
Join Date: Apr 2004
Location: ny, ny
Posts: 224
sending trigger email in excel

The user enters a date. If the system date is 10 days before the specified date, i need to trigger an email through excel. I have used docmd.sendobject but it doesnt seem to work. Could some one help me out plz

Thank you
Reply With Quote
  #2 (permalink)  
Old 03-03-05, 11:47
DavidCoutts DavidCoutts is offline
Registered User
 
Join Date: Jan 2004
Location: Aberdeen, Scotland
Posts: 1,067
How about something like this
Code:
'reference Microsoft Outlook 10.0 Object Library
Sub SendMail()
    Dim oOutlook As Outlook.Application
    Dim oNamespace As Outlook.NameSpace
    Dim ofolder As Outlook.MAPIFolder
    Dim oMail As Outlook.MailItem
    Dim oRecipient As Outlook.Recipient
    
    'create object variables
    Set oOutlook = CreateObject("Outlook.Application")
    Set oNamespace = oOutlook.GetNamespace("MAPI")
    Set ofolder = oNamespace.GetDefaultFolder(olFolderInbox)
    Set oMail = oOutlook.CreateItem(olMailItem)
    
    'set up mail
    With oMail
        Set oRecipient = .Recipients.Add("david.coutts4@btinternet.com")
        oRecipient.Type = olTo
        .Body = "This is some text"
        .Subject = "This is the Title"
        .Send
    End With

    'get rid of object variables
    Set oRecipient = Nothing
    Set oMail = Nothing
    Set ofolder = Nothing
    Set oNamespace = Nothing
    Set oOutlook = Nothing
End Sub

this will send a message via outlook
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On