A Microsoft Outlook email forum. Outlook Banter

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   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook - General Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

send email using outlook



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 16th 06, 11:31 AM posted to microsoft.public.access,microsoft.public.outlook
Richard
external usenet poster
 
Posts: 14
Default send email using outlook

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  
Old June 19th 06, 04:02 AM posted to microsoft.public.access,microsoft.public.outlook
[email protected]
external usenet poster
 
Posts: 2
Default send email using outlook

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  
Old June 20th 06, 10:08 AM posted to microsoft.public.access,microsoft.public.outlook
Richard
external usenet poster
 
Posts: 14
Default send email using outlook

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  
Old June 20th 06, 12:00 PM posted to microsoft.public.access,microsoft.public.outlook
[email protected]
external usenet poster
 
Posts: 2
Default send email using outlook


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  
Old June 22nd 06, 03:18 AM posted to microsoft.public.access,microsoft.public.outlook
Richard
external usenet poster
 
Posts: 14
Default send email using outlook

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  
Old June 22nd 06, 01:59 PM posted to microsoft.public.access,microsoft.public.outlook
Ron2006
external usenet poster
 
Posts: 2
Default send email using outlook

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
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
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


All times are GMT +1. The time now is 09:01 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.