Send Object Broken (1 Viewer)

jwindon

Registered User.
Local time
Today, 21:56
Joined
Aug 12, 2001
Messages
531
Hi all! I have a little something funky going on with this.

The command works to send information from a command button on a form. It works fine the first time I use it, but the next time I use it, I hit the command button and nothing happens. Is there some kind of refreshing that needs to take place?

KNOW ITS LONG. POINT IS THAT THE DOCMD>SEND OBJECT WORKS ONCE, then NOT AGAIN.

'set distribution email list as string

Dim DistList As String

DistList = "wnewton@kde.state.ky.us;vwright@kde.state.ky.us;awaldrid@kde.state.ky.us;kwaugh@kde.state.ky.us"

'send email, plug in data from form and subform

DoCmd.SendObject acSendNoObject, , , DistList, "ccomer@kde.state.ky.us", , "Request to Change Data -- School Number" & Me.SCHOOL_ID, "This message was generated automatically " _
& "from the Federal Perkin's Loan Forgiveness - Data Management Tool." & vbCrLf _
& vbCrLf & "The data currently being reported is as follows: " & vbCrLf _
& vbCrLf & "School Name: " & Me.SCH_NAME & vbCrLf & "Principal: " _
& Me.PSN_N_TITLE & " " & Me.PSN_N_FST & " " & Me.PSN_N_MIDDLE & " " & Me.PSN_N_LAST _
& vbCrLf & "Principal's Email: " & Me.EMAIL_ADDRESS & vbCrLf _
& "Address: " & Me.ADR_STR_NAME1 & " " & Me.ADR_STR_NAME2 & vbCrLf & "P.O. Box: " & Me.ADDREPO_BOX_NUMBER _
& vbCrLf & "City: " & Me.CITY_NAME & vbCrLf & "Zip Code: " _
& Me.ADR_ZIP5 & vbCrLf & "Phone: " & Me.PHN_NUMBER & vbCrLf & "Fax: " _
& Me.FAX_NUMBER & vbCrLf _
& "Grade Levels: " & Me.LOW_GRD_ABBR & " - " & Me.HIGH_GRD_ABBR _
& vbCrLf & vbCrLf & "The data should be corrected as follows: " & vbCrLf & vbCrLf _
& "New School Name: " & Me.Child19.Form.NewSchoolName & vbCrLf & "New Principal: " _
& Me.Child19.Form.NewPrincipalTitle & " " & Me.Child19.Form.NewPrincipalFirst & " " _
& Me.Child19.Form.NewPrincipalMiddle & " " & Me.Child19.Form.NewPrinicpalLast _
& vbCrLf & "New Principal Email: " & Me.Child19.Form.NewPrincipalEmail _
& vbCrLf & "New Address: " & Me.Child19.Form.NewStreet1 & " " _
& Me.Child19.Form.NewStreet2 & vbCrLf & "New P.O. Box: " & Me.Child19.Form.NewPOBox _
& vbCrLf & "New City: " & Me.Child19.Form.NewCity & vbCrLf & "New Zip: " _
& Me.Child19.Form.NewZip & vbCrLf & "New Phone: " & Me.Child19.Form.NewPhoneNumber _
& vbCrLf & "New Fax: " & Me.Child19.Form.NewFaxNumber & vbCrLf & "New Grade Levels Reported: " _
& Me.Child19.Form.NewLowGrade & " - " & Me.Child19.Form.NewHighGrade & vbCrLf _
& vbCrLf & vbCrLf & "Please respond to this email when the corrections have been made." _
& vbCrLf & vbCrLf & "Thank you."
 

Jon.N

Registered User.
Local time
Today, 21:56
Joined
Nov 24, 2000
Messages
43
I have also had similar problems with SendObject. I have found it doesn't work if you cancel the email and then try to sned it again. I also had a form that required the user to send emails to different people at different stages of completing the form. I found I could send the first but not subsequent emails. This was so even when I tried sending the emails in different orders.

I too would be most grateful if anyone knows the ins and outs of why this is so.
 

Jim Specht

New member
Local time
Today, 21:56
Joined
Sep 14, 2000
Messages
8
I'm all of the sudden having a somewhat simular problem but I'm using a different method to create the email. The error I keep getting is "Object Required". Don't understand why this is happening. Worked fine up until a few weeks ago. Makes me think that I don't have the MAPI activeX control registered right or something? Could use some insight as to what may be causing my situation as well.

Here is the portion of my code that deals w/ the email creation:

'Create the Email
'First intiated a session
If intSignOn = 1 Then
MAPISession.SignOn
intSignOn = 0
End If

'Get the ID and create a message
MAPIMessage.SessionID = MAPISession.SessionID
MAPIMessage.Compose

'Plug the information
With MAPIMessage
.RecipDisplayName = strTo
.MsgSubject = strSubject
.MsgNoteText = strMessage
.MsgIndex = -1
.AttachmentIndex = 0 'needs to be at 0 to start with


If Not IsNull(Me.lnkContract) Then
.AttachmentPathName = strContract 'using the if then???
If Not IsNull(Me.lnkConverSheet) Then
.AttachmentIndex = 1 'If there is an additional attachment you
End If
End If 'must increment the index prior to creating the attachment

If Not IsNull(Me.lnkConverSheet) Then 'if you increment without an addtional attachment the process fails
.AttachmentPosition = nLen - 1 'create attachment in a diff postion than the above
.AttachmentPathName = strCover
End If
End With

MAPIMessage.Send True 'Set send to True so that we can edit the
'information before sending it


thx,
js

[This message has been edited by Jim Specht (edited 05-21-2002).]
 

Jim Specht

New member
Local time
Today, 21:56
Joined
Sep 14, 2000
Messages
8
Well...never mind on my issue...I just wasn't creating my string correctly.

Both of you might find this send method as easy and more effective then the sendobject. You have to make sure that you have the MAPI activeX control (MSMAPI32.ocx) registered and added into your VB references...but it works great.

Windon...I have put your information into the format which I believe would be suitible for what you are trying to achive. Let me know how it works out if you decide to try it. Good luck.

Private Sub YourButton_Click()


On Error GoTo Err_YourButton_Click

Dim strTo As String
Dim strSubject As String
Dim strMessage As String


strTo = "Your email addresses@address.com"

strSubject = "Request to Change Data -- School Number" & Me.SCHOOL_ID


strMessage ="This message was generated automatically " _
& "from the Federal Perkin's Loan Forgiveness - Data Management Tool." & vbCrLf _
& vbCrLf & "The data currently being reported is as follows: " & vbCrLf _
& vbCrLf & "School Name: " & Me.SCH_NAME & vbCrLf & "Principal: " _
& Me.PSN_N_TITLE & " " & Me.PSN_N_FST & " " & Me.PSN_N_MIDDLE & " " & Me.PSN_N_LAST _
& vbCrLf & "Principal's Email: " & Me.EMAIL_ADDRESS & vbCrLf _
& "Address: " & Me.ADR_STR_NAME1 & " " & Me.ADR_STR_NAME2 & vbCrLf & "P.O. Box: " & Me.ADDREPO_BOX_NUMBER _
& vbCrLf & "City: " & Me.CITY_NAME & vbCrLf & "Zip Code: " _
& Me.ADR_ZIP5 & vbCrLf & "Phone: " & Me.PHN_NUMBER & vbCrLf & "Fax: " _
& Me.FAX_NUMBER & vbCrLf _
& "Grade Levels: " & Me.LOW_GRD_ABBR & " - " & Me.HIGH_GRD_ABBR _
& vbCrLf & vbCrLf & "The data should be corrected as follows: " & vbCrLf & vbCrLf _
& "New School Name: " & Me.Child19.Form.NewSchoolName & vbCrLf & "New Principal: " _
& Me.Child19.Form.NewPrincipalTitle & " " & Me.Child19.Form.NewPrincipalFirst & " " _
& Me.Child19.Form.NewPrincipalMiddle & " " & Me.Child19.Form.NewPrinicpalLast _
& vbCrLf & "New Principal Email: " & Me.Child19.Form.NewPrincipalEmail _
& vbCrLf & "New Address: " & Me.Child19.Form.NewStreet1 & " " _
& Me.Child19.Form.NewStreet2 & vbCrLf & "New P.O. Box: " & Me.Child19.Form.NewPOBox _
& vbCrLf & "New City: " & Me.Child19.Form.NewCity & vbCrLf & "New Zip: " _
& Me.Child19.Form.NewZip & vbCrLf & "New Phone: " & Me.Child19.Form.NewPhoneNumber _
& vbCrLf & "New Fax: " & Me.Child19.Form.NewFaxNumber & vbCrLf & "New Grade Levels Reported: " _
& Me.Child19.Form.NewLowGrade & " - " & Me.Child19.Form.NewHighGrade & vbCrLf _
& vbCrLf & vbCrLf & "Please respond to this email when the corrections have been made." _
& vbCrLf & vbCrLf & "Thank you."


'Create the Email
'First intiated a session
If intSignOn = 1 Then
MAPISession.SignOn
intSignOn = 0
End If

'Get the ID and create a message
MAPIMessage.SessionID = MAPISession.SessionID
MAPIMessage.Compose

'Plug in the information
With MAPIMessage
.RecipDisplayName = strTo
.MsgSubject = strSubject
.MsgNoteText = strMessage
End With


MAPIMessage.Send True 'Set send to True so that we can edit the
'information before sending it
Exit_YourButton_Click:
Exit Sub

Err_YourButton_Click:
MsgBox Err.Description


Resume Exit_YourButton_Click


End Sub
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 15:56
Joined
Feb 28, 2001
Messages
27,319
One of the things that works best for this class of problem is to make sure you close the object in your code at the end of the send operation and re-open it fresh for the next send. That forces a complete reset of the object's stored properties. It cleans out the detritus left over from any prior operation. Just opening it again won't help if it hasn't been properly closed.

Other objects also behave in a funky way (not limited to code behind Access) if you fail to close them correctly and try to re-enter the code for another action of the same type as the first one.
 

jwindon

Registered User.
Local time
Today, 21:56
Joined
Aug 12, 2001
Messages
531
Doc Man,

That was my initial thought. (refreshing)

Forgive my ignorance, but just how would I do that?

Thanks.
 

Users who are viewing this thread

Top Bottom