Question : Access Program Which Sends An Email

OS: Windows Vista
Application: Microsoft Access 2003 and 2007
I wrote a program which someone can request a query or report an send an email. The email is sent in 2003. But, the email is not sent when opening and using the form in access 2007. I took the code from the internet to send the email. I provided
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:
Dim bStarted As Boolean
    Dim oOutlookApp As Outlook.Application
    Dim oItem As Outlook.MailItem
    
    
    On Error Resume Next

    'Get Outlook if it's running
    Set oOutlookApp = GetObject(, "Outlook.Application")
    If Err <> 0 Then
    'Outlook wasn't running, start it from code
    Set oOutlookApp = CreateObject("Outlook.Application")
    bStarted = True
    End If

'Create a new mailitem
    Set oItem = oOutlookApp.CreateItem(olMailItem)

    With oItem
    'Set the recipient for the new email
    If infoReqMod.ReqInfoData.RptOpt = 1 Then
        .To = "[email protected]"
    ElseIf infoReqMod.ReqInfoData.RptOpt = 2 Then
        .To = "DL KNA SSC A/P METRICS AND TECHNOLOGY"
    ElseIf infoReqMod.ReqInfoData.RptOpt = 3 Then
        .To = "[email protected]"
    End If
    'Set the recipient for a copy
        .CC = "[email protected]"
    'Set the subject
    .Subject = "Information Request"
    'The content of the document is used as the body for the email
    .Body = infoReqMod.CreateBody
    
    If infoReqMod.attachments.blnHaveAttach = True Then
        Dim i As Integer
        
        For i = 0 To infoReqMod.attachments.intCnt - 1
            .attachments.Add infoReqMod.attachments.strAttach(i)
        Next
    End If
    
    .Send
End With

If bStarted Then
    'If we started Outlook from code, then close it
    oOutlookApp.Quit
End If

Answer : Access Program Which Sends An Email

Yes.  A refrigerator is a heat pump.
To make the inside colder, it has to make the outside hotter.
Random Solutions  
 
programming4us programming4us