Microsoft
Software
Hardware
Network
Question : Using Template Files and SendObject in a Macro
I need to send out emails from an access 2000 database. The email has an excel spreadsheet attached for the client to enter some data on it. I want to use a specific template for the mail, because the mail text field on the SendObject dialogue box has a limit to the number of characters. I have created a template by saving a .oft file from within Outlook. However, when I identify the template on the SendObject dialogue box (giving the full path) the resultant email is blank. In other words the template contents have not been used.
Can anyone help me to send an HTML formatted mail from access with this query/excel spreadsheet attached.
Answer : Using Template Files and SendObject in a Macro
why don't you post your current SendObject function and i'll use the code found in that link to your advantage...
you'll need to set a VBA reference to Microsoft Outlook (Tools > References while in the VBA editor)
also, i'll need the HTML of the e-mail template.
Andrew
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Appl
ication")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMa
ilItem)
With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Nancy Davolio")
objOutlookRecip.Type = olTo
' Add the CC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Michael Suyama")
objOutlookRecip.Type = olCC
' Add the BCC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Andrew Fuller")
objOutlookRecip.Type = olBCC
' Set the Subject, Body, and Importance of the message.
.Subject = "This is an Automation test with Microsoft Outlook"
'.Body we're not going to use this because we want to use HTML
.HTMLBody = "This should be
bold.
"& vbCrLf & vbCrLf 'the vbCrLf is line break
.Importance = olImportanceHigh 'High importance
' Add attachments to the message.
Dim AttachmentPath As String
AttachmentPath = "C:/somefolder/somefile.xl
s"
Set objOutlookAttach = .Attachments.Add(Attachmen
tPath)
' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next
' Should we display the message before sending or just send it?
'.Display 'take the ' out from before this to display it instead of sending it
.Send
End If
End With
Set objOutlook = Nothing 'close the outlook session
Random Solutions
Configure ISA 2004 as Backend Firewall
Fast Tape Less Backup Software
Outlook Express 6.0 Message display incorrect
SQL 2005 - An expression of non-boolean type specified in a context where a condition is expected, near 'THEN'.
changing formview background color
What is the difference between the following forest trust, domain trust, domain enternal trust:
How can I compare float data?
Hook and modify Windows Messages (even under Windows CE)
MYSQL Webservice Vb.net
Silverlight markup question (Canvas with Nested Grid)