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 and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Automating Outlook from within Access



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old November 19th 07, 05:30 PM posted to microsoft.public.outlook.program_vba
Tylendal
external usenet poster
 
Posts: 13
Default Automating Outlook from within Access

Im attempting to automate and Outlook Email send from within an Access
application. This is the code I'm using.

Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment

Dim mMgrAddy As String
Dim mEmpAddy As String

mBody = "This is test of the olOriginator MailItem"

' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")

' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(mEmpAddy)
objOutlookRecip.Type = olTo

' Add the From recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(mMgrAddy)
objOutlookRecip.Type = olBCC

' Set the Subject, Body, and Importance of the message.
.Subject = "This is a TEST Email"
.Body = mBody & vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High importance

' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next

' Should we display the message before sending?
If DisplayMsg Then
.Display
Else
.Save
.Send
End If
End With

My question has to do with the "From" button which opens Choose Sender when
working directly in Outlook. The person running the Access application has
rights to a specific email addy they can use but I cant seem to figure out
how to make the application use the "From" or Choose Sender Outlook feature.

Appreciate any assistance on this.

Thanks
Fred Alyea

  #2  
Old November 19th 07, 06:31 PM posted to microsoft.public.outlook.program_vba
JP[_2_]
external usenet poster
 
Posts: 18
Default Automating Outlook from within Access

Check out the ".SentOnBehalfOfName" property -- you can use it to
specify a sender


HTH,
JP




On Nov 19, 11:30 am, Tylendal
wrote:
Im attempting to automate and Outlook Email send from within an Access
application. This is the code I'm using.

Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment

Dim mMgrAddy As String
Dim mEmpAddy As String

mBody = "This is test of the olOriginator MailItem"

' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")

' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(mEmpAddy)
objOutlookRecip.Type = olTo

' Add the From recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(mMgrAddy)
objOutlookRecip.Type = olBCC

' Set the Subject, Body, and Importance of the message.
.Subject = "This is a TEST Email"
.Body = mBody & vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High importance

' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next

' Should we display the message before sending?
If DisplayMsg Then
.Display
Else
.Save
.Send
End If
End With

My question has to do with the "From" button which opens Choose Sender when
working directly in Outlook. The person running the Access application has
rights to a specific email addy they can use but I cant seem to figure out
how to make the application use the "From" or Choose Sender Outlook feature.

Appreciate any assistance on this.

Thanks
Fred Alyea


  #3  
Old November 19th 07, 11:47 PM posted to microsoft.public.outlook.program_vba
Tylendal
external usenet poster
 
Posts: 13
Default Automating Outlook from within Access

Thank you...

I was trying to find this property without success. Would it be possibe for
you to supply me with simple syntax for its use.

Thanks
Fred Alyea


"JP" wrote:

Check out the ".SentOnBehalfOfName" property -- you can use it to
specify a sender


HTH,
JP




On Nov 19, 11:30 am, Tylendal
wrote:
Im attempting to automate and Outlook Email send from within an Access
application. This is the code I'm using.

Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment

Dim mMgrAddy As String
Dim mEmpAddy As String

mBody = "This is test of the olOriginator MailItem"

' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")

' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(mEmpAddy)
objOutlookRecip.Type = olTo

' Add the From recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(mMgrAddy)
objOutlookRecip.Type = olBCC

' Set the Subject, Body, and Importance of the message.
.Subject = "This is a TEST Email"
.Body = mBody & vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High importance

' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next

' Should we display the message before sending?
If DisplayMsg Then
.Display
Else
.Save
.Send
End If
End With

My question has to do with the "From" button which opens Choose Sender when
working directly in Outlook. The person running the Access application has
rights to a specific email addy they can use but I cant seem to figure out
how to make the application use the "From" or Choose Sender Outlook feature.

Appreciate any assistance on this.

Thanks
Fred Alyea



  #4  
Old November 20th 07, 12:53 AM posted to microsoft.public.outlook.program_vba
JP[_2_]
external usenet poster
 
Posts: 18
Default Automating Outlook from within Access

It's a property of the MailItem so you would need to include it in the
appropriate With statement. I added it into your code below. Note that
the "send on behalf of" option only works if you are set up with the
authority to send emails on behalf of someone else. If you aren't set
up as a delegate for that user/mailbox, the email may not be sent.


Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment


Dim mMgrAddy As String
Dim mEmpAddy As String


mBody = "This is test of the olOriginator MailItem"


' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")


' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)


With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(mEmpAddy)
objOutlookRecip.Type = olTo

.SentOnBehalfOfName = "

' Add the From recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(mMgrAddy)
objOutlookRecip.Type = olBCC


' Set the Subject, Body, and Importance of the message.
.Subject = "This is a TEST Email"
.Body = mBody & vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High importance


' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next


' Should we display the message before sending?
If DisplayMsg Then
.Display
Else
.Save
.Send
End If
End With



HTH,
JP



On Nov 19, 5:47 pm, Tylendal
wrote:
Thank you...

I was trying to find this property without success. Would it be possibe for
you to supply me with simple syntax for its use.

Thanks
Fred Alyea

  #5  
Old November 20th 07, 12:55 AM posted to microsoft.public.outlook.program_vba
JP[_2_]
external usenet poster
 
Posts: 18
Default Automating Outlook from within Access

ps Fred - if you click on a blank line in your code inside the "With
objOutlookMsg" statement, type a "." (period) and you should get an
Intellisense dropdown list of the properties available for the
MailItem. You can simply select one and then hit F1 to get help on
what it does.


HTH,
JP

On Nov 19, 5:47 pm, Tylendal
wrote:
Thank you...

I was trying to find this property without success. Would it be possibe for
you to supply me with simple syntax for its use.

Thanks
Fred Alyea



  #6  
Old November 20th 07, 01:30 AM posted to microsoft.public.outlook.program_vba
Tylendal
external usenet poster
 
Posts: 13
Default Automating Outlook from within Access

Thanks JP... this is just what im looking for. Appreciate the updated code,
was thinking that was the way that property worked but was not sure. This
adds the needed functionally to the application I have written.

Fred Alyea



"JP" wrote:

ps Fred - if you click on a blank line in your code inside the "With
objOutlookMsg" statement, type a "." (period) and you should get an
Intellisense dropdown list of the properties available for the
MailItem. You can simply select one and then hit F1 to get help on
what it does.


HTH,
JP

On Nov 19, 5:47 pm, Tylendal
wrote:
Thank you...

I was trying to find this property without success. Would it be possibe for
you to supply me with simple syntax for its use.

Thanks
Fred Alyea




 




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
Automating Outlook from within Access Tylendal Outlook and VBA 0 November 19th 07 05:28 PM
Automating Outlook 2003 Andrew Kennard Outlook and VBA 4 February 12th 07 06:29 PM
Automating Outlook Andrew Kennard Outlook and VBA 1 December 20th 06 04:27 PM
Access automating Outlook using VBA no longer working [email protected] Outlook and VBA 5 May 9th 06 02:04 AM
Automating folder export from Outlook to Access [email protected] Outlook and VBA 1 March 6th 06 07:15 PM


All times are GMT +1. The time now is 11:28 AM.


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.