SendObject problem

hollering

Registered User.
Local time
Today, 18:24
Joined
Feb 15, 2005
Messages
38
I'm trying to use DoCmd.SendObject to send an email alert when a user adds a new record to a certian table. Problem is that when I run my little email subroutine, all I get is an error message that says:

"Object doesn't support this property or method"

Here's what my code looks like...if anyone can help with this I would greatly appreciate it.

Code:
Public Sub SendEmailAlert()

Dim mailRecipient As String
Dim mailSubject As String
Dim mailBody As String
Dim mailHeader As String
Dim mailInfo As String

mailRecipient = "email@email.com"
mailSubject = "DM Design Request for Approval"
mailHeader = "Long string"
mailInfo = "Long string

mailBody = mailHeader & vbCrLf & vbCrLf & mailInfo

DoCmd.SendObject , , , , mailRecipient, , , mailSubject, mailBody, False

End Sub
 
You're calling a command to send an object, but you're not sending any object.

Try:
DoCmd.SendObject acSendNoObject , , , mailRecipient, , , mailSubject, mailBody, False

You do realize that with outlook a msgbox will come up asking if the email should be sent...giving the user the ability to not send this message.
 
Last edited:
I have also tried that. acSendNoObject is implied by leaving it blank. As I was looking into this I realized that sendObject isn't working on other databases either...ones that have been used over and over again....so I think it has something to do with Windows Messaging. *sigh*
 
Again I thank you for your quick reply modest. Unfortunately, I left out the detail that I am working in Access 97. I think as soon as I get done posting this I'm going to try it in Access 2000 just to see whether it's an Access issue or otherwise, since my 2000 installation has SP3. However, the finished product must be in Access 97 :mad:
 
Here's some code found from a different forum:

Code:
[COLOR=Green]' Here is an example of creating an email message from Access.
' Enable the library reference to "Microsoft Outlook 9.0 Object Library" (Or version you are using)[/COLOR]

[COLOR=Blue]Private Sub txtEmail_Click()[/COLOR]
Dim ol As New Outlook.Application
Dim olMail As Outlook.MailItem
Dim strCC As String 

[COLOR=Green]' To send multi CC's
' strCC = "someaddres@domain.com" & ";" & "anotheraddress@domain.com" [/COLOR] 

Set olMail = ol.CreateItem(olMailItem)
 
With olMail  
	[COLOR=Green]' Rem out any property not needed below  [/COLOR] 
        .To = "address@domain.com" 
	'[COLOR=Green] Who to send email to  
	'.CC = strCC ' Who gets CC .. if needed  
	'.BCC = "address2@domain.com" ' Who gets BCC .. if needed  
	'.Importance = olImportanceHigh  'High importance[/COLOR]  
	.attachments.Add "C:\FolderName\FileAttachment1.txt" 	[COLOR=Green]' attachment 1  
        '.Attachments.Add "C:\FolderName\FileAttachment2.txt" ' attachment 2 ... if needed  [/COLOR] 
	.Subject = "Text for Suject"  
	.Body = "Main Message in body ..."  
	[COLOR=Green]'.Display  [/COLOR] 
	.Send
End With 

Set olMail = Nothing
Set ol = Nothing 

[COLOR=Blue]End Sub[/COLOR]
 
Has anyone come across similar code using Groupwise? We use Groupwise as our email client here. This code looks great...I've seen similar examples and would love to have that level of customization, but most of the computers here don't have Outlook, and none use it as their main email client.

Related question...is there any other way to send an automated email from Access without using SendObject? I've generally had nothing but problems using SendObject in the past.
 
well you'll see that the above code doesn't use sendobject... I'm not too familiar with Groupwise.. all I've really seen of it is basic help posted on www.techonthenet.com

-modest
 
Code:
Option Explicit
 
Sub Groupwise_Mail() 
	Dim objGroupWise As Object 
	Dim objAccount As Object 
	Dim objMessages As Object 
	Dim objMessage As Object 
	Dim objMailBox As Object 
	Dim objRecipients As Object 
	Dim objRecipient As Object 
	Dim objAttachment As Object 
	Dim objAttachments As Object 
	Dim objMessageSent As Variant 
	Dim Subject As String, Attachment As String, Recipient As String, Bodytext As String 

   On Error GoTo Errorhandling 
	Subject = "Test" 
	Attachment = ThisWorkbook.Path & "\Test.xls" 
	Recipient = "epost@mail.com" 
	Bodytext = "blah blah blah" 

	Set objGroupWise = CreateObject("NovellGroupWareSession") 
	Set objAccount = objGroupWise.Login 
	Set objMailBox = objAccount.MailBox 
	Set objMessages = objMailBox.Messages 
	Set objMessage = objMessages.Add("GW.MESSAGE.MAIL", "Draft") 
	Set objRecipients = objMessage.Recipients 
	Set objRecipient = objRecipients.Add(Recipient) 
	Set objAttachments = objMessage.Attachments 
	Set objAttachment = objAttachments.Add(Attachment) 

	With objMessage 
		.Subject = Subject 
		.Bodytext = Bodytext 
	End With 

	Set objMessageSent = objMessage.Send 


   ExitHere: 
	Set objGroupWise = Nothing 
	Set objAccount = Nothing 
	Set objMailBox = Nothing 
	Set objMessages = Nothing 
	Set objMessage = Nothing 
	Set objRecipients = Nothing 
	Set objAttachments = Nothing 
	Set objRecipient = Nothing 
	Set objAttachment = Nothing 

	Exit Sub 


   Errorhandling: 
	MsgBox Err.Description & " " & Err.Number 
	Resume ExitHere 

End Sub
This was taken from another forum.. done in excel (you can use main stuff though)

also check out:
http://www.ipdg3.com/sourcecoderesults.php?option=search_sourcecode&sc=VB_&ss=Groupwise&match=cp&offset=0


Hope this helps,
modest
 
Thanks, that last code was brilliant and worked. I wish it would open the message to allow editing and confirm it was sent.
 

Users who are viewing this thread

Back
Top Bottom