wiselittlemonkeys
Martin
- Local time
- Today, 22:21
- Joined
- Apr 10, 2008
- Messages
- 1
Am using Access 2003 and outlook 2003. I have a database that is sending emails via outlook but I what to populate the From email address. Below is the main code, which works but the FROM (olorgintor) field is blank. Can any help?
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
'## Add the From recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(strMailFrom)
objOutlookRecip.Type = olOriginator
'## Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(strMailTo)
objOutlookRecip.Type = olTo
'## Add the CC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(strMailCC)
objOutlookRecip.Type = olCC
'## Set the Subject, Body, and Importance of the message.
.Subject = strMailTitleLg
.Body = strMailGreet & vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High importance
'## Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next
.Display
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing

Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
'## Add the From recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(strMailFrom)
objOutlookRecip.Type = olOriginator
'## Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(strMailTo)
objOutlookRecip.Type = olTo
'## Add the CC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(strMailCC)
objOutlookRecip.Type = olCC
'## Set the Subject, Body, and Importance of the message.
.Subject = strMailTitleLg
.Body = strMailGreet & vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High importance
'## Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next
.Display
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
