![]() |
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. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
Hi
I am using access to automate sending emails using outlook. How do I send emails without opening Outlook or can I? Many thanks in advance Richard |
#2
|
|||
|
|||
![]()
I have not used the following code - I usually use the Outlook Express
client since my work is always on corporate standard clients with Outlook set - but it seems easy enough; you would only need to automate collection/setting of e-mail strings: **Module (space formatting added to make it easier to read): Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long '**Code attached to a button: Dim stext As String 'Hard coded parts of the e-mail, stripped down to the minimum stext = ?" stext = stext & "&Subject=" & "Document attached" stext = stext & "&Body=" & "Please find the document attached" 'Launch default e-mail Call ShellExecute(hwnd, "open", stext, vbNullString, vbNullString, SW_SHOWNORMAL) Richard wrote: Hi I am using access to automate sending emails using outlook. How do I send emails without opening Outlook or can I? Many thanks in advance Richard |
#3
|
|||
|
|||
![]()
Hi James
I have a code to automate using Outlook Express but I can't seem to be able to set attachments. Does you code allow you to set attachments? Thanks and regards Richard wrote in message oups.com... I have not used the following code - I usually use the Outlook Express client since my work is always on corporate standard clients with Outlook set - but it seems easy enough; you would only need to automate collection/setting of e-mail strings: **Module (space formatting added to make it easier to read): Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long '**Code attached to a button: Dim stext As String 'Hard coded parts of the e-mail, stripped down to the minimum stext = ?" stext = stext & "&Subject=" & "Document attached" stext = stext & "&Body=" & "Please find the document attached" 'Launch default e-mail Call ShellExecute(hwnd, "open", stext, vbNullString, vbNullString, SW_SHOWNORMAL) Richard wrote: Hi I am using access to automate sending emails using outlook. How do I send emails without opening Outlook or can I? Many thanks in advance Richard |
#4
|
|||
|
|||
![]() I haven't used the code provided; I wrote that in the first sentence. I do have Outlook code, and to send mail one needs to replace .Display with .Send in the with area. This code will allow attachments: Sub RequestAccess() Dim objOutlookApp As Object Dim objOutlookMail As Object Set objOutlookApp = CreateObject("Outlook.Application") Set objOutlookMail = objOutlookApp.CreateItem(0) Dim strRecipients As String Dim CurrentUser As String strRecipients = "[Put you recipients here]" With objOutlookMail .To = strRecipients .Subject = "Request..." .Display End With 'releases resources from outlook and associated components If Not objOutlookApp Is Nothing Then objOutlookApp.Quit If Not objOutlookMail Is Nothing Then Set objOutlookMail = Nothing End If Set objOutlookApp = Nothing End If Exit Sub ErrorTrap: MsgBox Err.Number & " : " & Err.Description, vbOKOnly, "Error" 'releases resources from outlook and associated components If Not objOutlookApp Is Nothing Then objOutlookApp.Quit If Not objOutlookMail Is Nothing Then Set objOutlookMail = Nothing End If Set objOutlookApp = Nothing End If End Sub Richard wrote: Hi James I have a code to automate using Outlook Express but I can't seem to be able to set attachments. Does you code allow you to set attachments? Thanks and regards Richard wrote in message oups.com... I have not used the following code - I usually use the Outlook Express client since my work is always on corporate standard clients with Outlook set - but it seems easy enough; you would only need to automate collection/setting of e-mail strings: **Module (space formatting added to make it easier to read): Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long '**Code attached to a button: Dim stext As String 'Hard coded parts of the e-mail, stripped down to the minimum stext = ?" stext = stext & "&Subject=" & "Document attached" stext = stext & "&Body=" & "Please find the document attached" 'Launch default e-mail Call ShellExecute(hwnd, "open", stext, vbNullString, vbNullString, SW_SHOWNORMAL) Richard wrote: Hi I am using access to automate sending emails using outlook. How do I send emails without opening Outlook or can I? Many thanks in advance Richard |
#5
|
|||
|
|||
![]()
Thanks James
Appreciate your help and time Richard wrote in message ups.com... I haven't used the code provided; I wrote that in the first sentence. I do have Outlook code, and to send mail one needs to replace .Display with .Send in the with area. This code will allow attachments: Sub RequestAccess() Dim objOutlookApp As Object Dim objOutlookMail As Object Set objOutlookApp = CreateObject("Outlook.Application") Set objOutlookMail = objOutlookApp.CreateItem(0) Dim strRecipients As String Dim CurrentUser As String strRecipients = "[Put you recipients here]" With objOutlookMail .To = strRecipients .Subject = "Request..." .Display End With 'releases resources from outlook and associated components If Not objOutlookApp Is Nothing Then objOutlookApp.Quit If Not objOutlookMail Is Nothing Then Set objOutlookMail = Nothing End If Set objOutlookApp = Nothing End If Exit Sub ErrorTrap: MsgBox Err.Number & " : " & Err.Description, vbOKOnly, "Error" 'releases resources from outlook and associated components If Not objOutlookApp Is Nothing Then objOutlookApp.Quit If Not objOutlookMail Is Nothing Then Set objOutlookMail = Nothing End If Set objOutlookApp = Nothing End If End Sub Richard wrote: Hi James I have a code to automate using Outlook Express but I can't seem to be able to set attachments. Does you code allow you to set attachments? Thanks and regards Richard wrote in message oups.com... I have not used the following code - I usually use the Outlook Express client since my work is always on corporate standard clients with Outlook set - but it seems easy enough; you would only need to automate collection/setting of e-mail strings: **Module (space formatting added to make it easier to read): Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long '**Code attached to a button: Dim stext As String 'Hard coded parts of the e-mail, stripped down to the minimum stext = ?" stext = stext & "&Subject=" & "Document attached" stext = stext & "&Body=" & "Please find the document attached" 'Launch default e-mail Call ShellExecute(hwnd, "open", stext, vbNullString, vbNullString, SW_SHOWNORMAL) Richard wrote: Hi I am using access to automate sending emails using outlook. How do I send emails without opening Outlook or can I? Many thanks in advance Richard |
#6
|
|||
|
|||
![]()
The following will work: (use only the parts of the email message that
you need). These are all of the aspects of outlook email that I have found so far. This assums the button name is command0. If Outlook is NOT open when this is done, then the email simply goes into the outbox. ============================== Private Sub Command0_Click() On Error GoTo Error_Handler Dim objOutlook As Outlook.Application Dim objEmail As Outlook.MailItem Set objOutlook = CreateObject("Outlook.application") Set objEmail = objOutlook.CreateItem(olMailItem) With objEmail .To = " .CC = " .BCC = " .Subject = "Look at this sample attachment" .body = "The body doesn't matter, just the attachment" .Attachments.Add "C:\Test.htm" '.attachments.Add "c:\Path\to\the\next\file.txt" ' ======================================== ' next two only if the body is to include HTML .bodyformat = 2 ' not necessary if no html this makes it html ' 1 is text 2 is HTML 3 is RTF .htmlbody = Chr(13) & Chr(13) & _ "body" & _ "Table" &_ "tr" &_ "tdb Date: /b/td" & _ "td" & Date & "/td" & _ "/tr" &_ "tr" &_ "td/td" & _ "td/td" & _ "/tr" &_ " /Table" &_ "/body" '============================== .Send '.ReadReceiptRequested '.Display ' to see the email have have user actually do the send ' don't use the .Send if you are using Display ' End With Exit_He Set objOutlook = Nothing Exit Sub Error_Handler: MsgBox Err & ": " & Err.Description Resume Exit_Here End Sub =================================== |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
My outlook email/forms do not send, just get a blank email. HELP! | Lara | Outlook - Using Forms | 2 | March 9th 06 07:02 PM |
I can send email but cannot receive email in Outlook 2003 | Stephen | Outlook - General Queries | 1 | February 4th 06 09:59 PM |
I can send email but cannot receive email in Outlook 2003 | Todd | Outlook - General Queries | 0 | January 23rd 06 11:33 PM |
Change Default Send email form to Custom Send email Form | Sue Mosher [MVP-Outlook] | Outlook - Using Forms | 0 | January 20th 06 06:33 PM |
can't make outlook express default email app when send page by email | merdrum | Outlook Express | 3 | January 16th 06 03:28 AM |