![]() |
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
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 |