Results 1 to 1 of 1
Thread: Sending emails from Access97
2001-05-03, 10:52 #1
- Join Date
- Jan 2001
- Nottingham, UK, Nottinghamshire, England
- Thanked 0 Times in 0 Posts
Sending emails from Access97
Using Access97, Outlook 2000, Exchange Server, under Win NT
We have a problem tracking system written as an Access 97 application, that sends emails of third party problems and queries to the external third party. This works quite well by sending an Access report of the problem using the DoCmd.SendObject method - but I really wanted to send the third-party company a much nicer formatted email. We've not long had Outlook 2000 installed, and so I can now use VBA to access Outlook from Access. So I tried by creating a nice Outlook mail form, and then filling in the blanks from Access and sending it (you know, MyMail.Send and all that). When I tested it by sending it to myself (internal email address), it worked just fine, so I contacted the external firm and sent them some dummy test emails.
These, however, did NOT work! Oh sure, the coding *worked* and no errors were reported, but what the external company received was only a corrupted version of my default mailitem (it contained a background and a signature - they got the signature, with the background as an attachment!). I verified what they were telling me by sending the emails to my home addresses, and I got just the same. But to my (or any other) internal email address - bingo! Just as I wanted! Has anyone any idea why this should be? The Outlook form was created from my customised mailitem (though no traces remain of that now), and the Compose and Read pages are the same (ie no distinct pages).
My code is as follows :
Dim MyApp As Outlook.Application
Dim MyMail As Outlook.MailItem
Dim oOutNameSpace As Outlook.NameSpace
Dim oOutFolder As Outlook.MAPIFolder
Set MyApp = GetObject(, "Outlook.Application")
Set oOutNameSpace = MyApp.GetNamespace("MAPI")
Set oOutFolder = oOutNameSpace.GetDefaultFolder(olFolderNotes)
Set MyMail = oOutFolder.Items.Add("IPM.Note.Functional Query") ' My user designed mail item
' Set MyMail = MyApp.CreateItemFromTemplate _
("driveathmailitem.oft") - I tried this way too!
.To = "external email address"
.UserProperties("zzDate Raised") = Me![Date Raised]
.UserProperties("zzRaised By") = Me![Raised By]
.UserProperties("zzPriority") = Me!Priority
.UserProperties("zzReply Required By") = Me![Date Required By]
.UserProperties("zzSub Systems") = Me![Sub System]
.UserProperties("zzQuery") = Me!Query
.UserProperties("zzLog Number") = Me![Log Number]
If Not IsNull(Me![HEAT Reference]) Then
.UserProperties("zzHEAT Reference") = Me![HEAT Reference]
Set MyMail = Nothing
Set MyApp = Nothing
Thanks in advance for any help and/or advice.