Sending e-mails from Access using Outlook [resolved]
Hi this is a problem which I'm realy stuck on. For a bit of background we use Exchange 2003 as are mailserver and have outlook 2000 clients.
I have an e-mailer program which takes an e-mail it recives and forward it out again. The problem is we have a client complaing saying he only wants the e-mail we send him to be in plain text. If I send the program straight from Outlook it's fine, but for some reson when I use the below code to send an e-mail it's sent as both plain text and HTML, anyone now how to change this.
VB Code:
Private Function sendemail(todest As String, subject As String, body As String) As Boolean
On Error GoTo sendwarning:
Dim fnam As String
Dim loopcounter As Integer
loopcounter = 0
Set objMailitem = objApp.CreateItem(olMailItem)
If addatt Then
Set myatts = myitem.Attachments
If myatts.Count > 0 Then
Set myatts = myitem.Attachments
Set objattachments = objMailitem.Attachments
Do While loopcounter < myatts.Count
loopcounter = loopcounter + 1
Set myatt = myatts(loopcounter)
fnam = myatt.FileName
If Mid(fnam, 1, 4) = "Page" Then
fnam = Mid(fnam, 1, 11)
End If
myatt.SaveAsFile fnam
objattachments.Add (fnam)
Loop
Else
Set myatt = Nothing
End If
End If
objMailitem.To = todest
objMailitem.subject = subject
objMailitem.body = body
objMailitem.Send
sendemail = True
Exit Function
sendwarning:
sendemail = False
End Function
Re: Sending e-mails from Access using Outlook
Re: Sending e-mails from Access using Outlook [resolved]
Thanks, is annoying when you can't figure something out. Should have done a search first (bad me) but didn't think it would be the kind of problm anyone else would have.
Thanks again
Re: Sending e-mails from Access using Outlook [resolved]
No, it's not your fault. The Office ActiveX EXE objects are extremely poorly documented. You have to dig hard and long to get any info on the internals of these objects.
Re: Sending e-mails from Access using Outlook [resolved]
Dave, instead of setting it to 1, wouldnt it be easier reading to set it to the const. - olFormatHTML ?
Re: Sending e-mails from Access using Outlook [resolved]
Quote:
Originally Posted by RobDog888
Dave, instead of setting it to 1, wouldnt it be easier reading to set it to the const. - olFormatHTML ?
Totally. But sometimes you don't get constants in VB, and I couldn't tell by the MSDN documentation so I just played it safe. Definately use constants if they are available to you.
Re: Sending e-mails from Access using Outlook [resolved]
Thats what I thought. :thumb: You dont get the const.'s when you are using
VBScript or are using late binding ;)
Re: Sending e-mails from Access using Outlook [resolved]
P.S. the MSDN docs say to use CdoBodyFormatText. I think its different in the VB IDE.
Re: Sending e-mails from Access using Outlook [resolved]
Depends on how his module code is. If he has a reference to Outlook added
then use the olFormatHTML. If not then its Access' CDO default reference, I
think is how it is?
Re: Sending e-mails from Access using Outlook [resolved]
ahem * cough * ahem - he wants plain text... :bigyello:
Re: Sending e-mails from Access using Outlook [resolved]
Doh! Thats right. olFormatPlain it is then. :blush: