Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 15th, 2003, 03:39 PM
wmt7 wmt7 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 3 wmt7 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Redemption and Outllook Problem

Greetings,

I am trying to loop through a query and send an email for each record in the results. I have all of that working fine - until I go to send the email. I am working in Access and Outlook XP. I have redemption installed as well - which seems to be working.

I had this working before and now can't quite get it to work.

After sending one message successfully I get and error on the objSafe.Send line.

It is a run-time error with the message "Method 'Update' not supported by automation object"

I have included a stripped down sample of the code I am attempting to use (a once had working)

Any insight would be great!!

CODE:

Function TestSend()

Set objSafe = CreateObject("Redemption.SafeMailItem")
Set objApp = CreateObject("Outlook.Application")
Set objItem = objApp.CreateItem(i)

For i = 1 To 10

objItem.To = "user@domain.com"
objItem.Subject = "Subject"
objItem.Body = "text"
objSafe.Item = objItem
objSafe.Send
Sleep 2000

Next i

End Function

Reply With Quote
  #2  
Old December 15th, 2003, 10:27 PM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
Would U close the objSafe object after send the first mail??U can check it..

Reply With Quote
  #3  
Old December 15th, 2003, 10:31 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,852 Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 47 m 6 sec
Reputation Power: 766
It doesn't look like you've posted the code that is giving the actual error.

Reply With Quote
  #4  
Old December 16th, 2003, 09:09 AM
wmt7 wmt7 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 3 wmt7 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Figured it out.....

A couple of changes that seemed to correct the code:

Put some of the "Set" statements within the loop

and

Making sure all the Items of SafeMail are not exactly the same through the iterations of the loop (at least not one right after another). Initially when testing I was looping through a repeating list of two addresses (the next address was always different).

I changed the list to all one address at one point and that is when it stop working (I however had the 'On Error resume Next' statement -which made me initially miss the error). Not sure why having all the same items creates an error ??

Here is the code that finally worked for me (I do need to clean it up - any ideas or reccomendations would be appreciated - I am rather new to this!)


Code Begin:

Option Compare Database

Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Function SendSafeMail()

Dim objApp As Outlook.Application
Dim objSafe As Redemption.SafeMailItem

' Create Objects

Set db = CurrentDb
Set rs = db.OpenRecordset("tblTest")

On Error Resume Next

'Get MS Word if it's running
Set objMSWord = GetObject(, "Word.Application")
objMSWord.Visible = True
If Err <> 0 Then
'MS Word wasn't running, start it from code
Set objMSWord = CreateObject("Word.Application")
bStarted = True
End If

Set objDoc = objMSWord.Documents.Open("C:\Documents and Settings\user\Desktop\express.doc", ReadOnly:=True)

' Returns Message Box if not Records returned.
If rs.RecordCount = 0 Then
MsgBox ("No Records To Mail")
End If

' Displays warning message with number of emails to be sent
rs.MoveLast
nB = vbExclamation + vbYesNo
mText = "You are about to send " & rs.RecordCount & " emails!! Do you want to continue?"
Msg = MsgBox(mText, vbYesNo + vbExclamation, "SENDING EMAIL")

If Msg = vbYes Then
rs.MoveFirst

With rs

Do Until .EOF

Set objSafe = CreateObject("Redemption.SafeMailItem")
Set objApp = CreateObject("Outlook.Application")
Set objItem = objApp.CreateItem(0)
Set objBar = objApp.ActiveExplorer.CommandBars("Standard")
Set objCmd = objBar.Controls("Send/Receive")
Set attchmnt = objItem.Attachments
attchmnt.Add "C:\Documents and Settings\user\Desktop\Express.doc"

objItem.To = ![EMAIL_ADDRESS]
objItem.Subject = "Subject Line"
objItem.Body = objDoc.Content
objItem.SentOnBehalfOfName = "SomeUser"
objSafe.Item = objItem
objSafe.Send
objCmd.Execute
Sleep 2000
.MoveNext


Loop

End With
End If

If bStarted Then
objDoc.Close False
objMSWord.Quit False
Set objMSWord = Nothing
End If

Set objItem = Nothing
Set objSafe = Nothing

End Function

END CODE

I created this because I got an unhappy response from our System's Admin for nailing our mail server with several thousand emails at once. This script automates the process vary nicely with a slight pause before sending the next message.



Thanks for the input!

Cheers!

PS some of this code is piecemealed by searching the web and copy/paste - so I do not take claim to all of it.

Reply With Quote
  #5  
Old December 16th, 2003, 06:34 PM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
I have read whole your code.I think u should modify these statement in the loop as it:
Set objSafe = CreateObject("Redemption.SafeMailItem")
Set objApp = CreateObject("Outlook.Application")
Set objItem = objApp.CreateItem(0)
Set objBar = objApp.ActiveExplorer.CommandBars("Standard")
Set objCmd = objBar.Controls("Send/Receive")

Do Until .EOF
Set attchmnt = objItem.Attachments
attchmnt.Add "C:\Documents and Settings\user\Desktop\Express.doc"
objItem.To = ![EMAIL_ADDRESS]
objItem.Subject = "Subject Line"
objItem.Body = objDoc.Content
objItem.SentOnBehalfOfName = "SomeUser"
objSafe.Item = objItem
objSafe.Send
objCmd.Execute
set attchmnt=nothing
Sleep 2000
.MoveNext

Loop

Set objCmd=Nothing
Set objBar=Nothing
Set objItem = Nothing
Set objSafe = Nothing
Set objApp=Nothing
...

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Redemption and Outllook Problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway