S
Synergy
Hello,
This is among the myriad of problems I have encountered since linking to SQL
Server Tables. The following snippet shows the method then flagging the
email as being sent. Outlook 2000 is the Client and server.
DoCmd.SendObject acSendReport, "OrderConfirmation", acFormatTXT, vSendTo, ,
vBCcTo, strSubject, strMessage, vPreview
[ordConfEmailed] = True
The entire method is below: Sometimes the email does not get sent, and no
error is generated, then it gets marked as being sent. This is a problem
for my client becuase they they can't take the time to call clients to see
if they received their confirmations.
Does anyone have any ideas on this???
Thanks and God Bless,
Mark A. Sam
On Error GoTo error_Section
'Check whether email has been sent for this order
If [ordConfEmailed] = True Then
If MsgBox("An Email has been sent for this order. Do you wish to resend
this confirmation?", vbYesNo + vbDefaultButton2) = vbNo Then
Exit Sub
End If
End If
Dim dbs As Database
Dim rsProds As Recordset
Dim rsCust As Recordset
Dim strCriteria As String
Dim vPreview As Boolean 'used to set the EditMessage argument for the
SendObject method
Dim vSendTo As String 'Used to set the recipient email addy for the
SendObject method
Dim vBCcTo As String 'Used to set the Blind CC for the SendObject method
Dim vDisclaimer As String
Set dbs = CurrentDb()
Set rsCust = dbs.OpenRecordset("Customers", dbOpenDynaset, dbSeeChanges)
Set rsProds = [ Products].Form.RecordsetClone
If rsProds.RecordCount = 0 Then 'If there are no products then the
confirmation isn't nesessary
MsgBox "There are no products entered in this order. Confirmation is
aborted."
Exit Sub
End If
'Determine if this is an Email or Fax send
strCriteria = "[CustID] = " & [ordCustID]
rsCust.FindFirst strCriteria
If rsCust.NoMatch Then
MsgBox "Customer Not Found. You must enter email address manually!"
[ViewEmail] = True
End If
Select Case rsCust![ConfMode]
Case 1 'Email Confirmation
' Redo***
vPreview = [ViewEmail] 'View email is a checkbox on the current form
vSendTo = Nz(rsCust![ConfEmail], "")
If IsNull(vSendTo) Or vSendTo = "" Then
MsgBox "No Confiramtion Email Address was set up for this customer.
You must enter email address manually!"
vPreview = True
End If
vBCcTo = "(e-mail address removed)"
vDisclaimer = "Merchandise covered by this confirmation is warranted to
be free from defects in workmanship " & _
"but not for any specific length of time, type or measure
of service. Claims for allowance will only " & _
"be recognized when presented in writing within 5 days of
receipt of material. No claims for labor, " & _
"transportation or consequential damages will be allowed.
The maximum liability for any claim predicated upon " & _
"defective merchandise is limited to replacement of
merchandise, or to repayment of the purchase price, " & _
"whichever may be elected by Synergy Tooling Systems,
Inc."
Dim strLineItems As String 'This is to hold the line item values from
the [ Products] subform
Dim vQty As String
Dim vPrice As String
Dim vExt As String
Dim vOrdTotal As String
'Create Email Subject line
Dim strSubject As String
strSubject = "Synergy Order Confirmation: " & [ordJob] & " PO: " &
[ordPO] & " Ref#: " & [ordCustRef]
'Create Email message
Dim strMessage As String
If Not IsNull(rsCust![ConfContact]) Then
strMessage = rsCust![ConfContact] & vbCrLf 'This is the first line
of the Message. If you move this you must remove the Null assignment below
Else
strMessage = ""
End If
strMessage = strMessage & [ordCustName] & vbCrLf & _
"PO Number: " & [ordPO] & vbCrLf & _
"Ref # " & [ordCustRef] & vbCrLf & _
"Required Date: " & [ordReqDate] & vbCrLf & _
"Synergy Order Number: " & [ordJob]
strLineItems = String(70, "-") & vbCrLf
strLineItems = strLineItems & "Qty" & Space(4) & "Description" &
Space(27) & "Price Ea " & "Total Price" & vbCrLf
strLineItems = strLineItems & String(70, "-") & vbCrLf
rsProds.MoveFirst
Do Until rsProds.EOF
vQty = Format(rsProds![detQty], "##0")
vPrice = Format(rsProds![detPrice], "#,0.00") '00
vExt = Format(rsProds![detExt], "#,0.00") '00
If Len(vExt) = 4 Then 'Adjust position of extention according to size
strLineItems = strLineItems & vQty & Space(7 - Len(vQty)) &
rsProds![detProdDescription] & Space(38 - Len(rsProds![detProdDescription]))
& Space(8 - Len(vPrice)) & vPrice & Space(18 - Len(vPrice) - (8 -
Len(vPrice))) & vExt & vbCrLf
ElseIf Len(vExt) = 5 Then 'Adjust position of extention according to
size
strLineItems = strLineItems & vQty & Space(7 - Len(vQty)) &
rsProds![detProdDescription] & Space(38 - Len(rsProds![detProdDescription]))
& Space(8 - Len(vPrice)) & vPrice & Space(17 - Len(vPrice) - (8 -
Len(vPrice))) & vExt & vbCrLf
ElseIf Len(vExt) = 6 Then
strLineItems = strLineItems & vQty & Space(7 - Len(vQty)) &
rsProds![detProdDescription] & Space(38 - Len(rsProds![detProdDescription]))
& Space(8 - Len(vPrice)) & vPrice & Space(16 - Len(vPrice) - (8 -
Len(vPrice))) & vExt & vbCrLf
ElseIf Len(vExt) = 8 Then
strLineItems = strLineItems & vQty & Space(7 - Len(vQty)) &
rsProds![detProdDescription] & Space(38 - Len(rsProds![detProdDescription]))
& Space(8 - Len(vPrice)) & vPrice & Space(14 - Len(vPrice) - (8 -
Len(vPrice))) & vExt & vbCrLf
ElseIf Len(vExt) = 9 Then
strLineItems = strLineItems & vQty & Space(7 - Len(vQty)) &
rsProds![detProdDescription] & Space(38 - Len(rsProds![detProdDescription]))
& Space(8 - Len(vPrice)) & vPrice & Space(13 - Len(vPrice) - (8 -
Len(vPrice))) & vExt & vbCrLf
Else
strLineItems = strLineItems & vQty & Space(7 - Len(vQty)) &
rsProds![detProdDescription] & Space(38 - Len(rsProds![detProdDescription]))
& Space(8 - Len(vPrice)) & vPrice & Space(16 - Len(vPrice) - (8 -
Len(vPrice))) & vExt & vbCrLf
End If
rsProds.MoveNext
Loop
vOrdTotal = Format([ Products].Form![Text5], "#,0.00") '00
strLineItems = strLineItems & Space(58) & String(9, "_") & vbCrLf
If Len(vOrdTotal) = 5 Then 'Adjust position of Total according to size
strLineItems = strLineItems & Space(62) & vOrdTotal
ElseIf Len(vOrdTotal) = 6 Then 'Adjust position of Total according to
size
strLineItems = strLineItems & Space(61) & vOrdTotal
'ElseIf Len(vOrdTotal) = 7 Then There is no case for 7 which is the
comma
'strLineItems = strLineItems & Space(59) & vOrdTotal
ElseIf Len(vOrdTotal) = 8 Then
strLineItems = strLineItems & Space(59) & vOrdTotal
ElseIf Len(vOrdTotal) = 9 Then
strLineItems = strLineItems & Space(57) & vOrdTotal
Else
strLineItems = strLineItems & Space(62) & vOrdTotal
End If
'strMessage = strMessage & vbCrLf & strLineItems & vbCrLf & _ (Line
items omitted from email body)
strMessage = strMessage & vbCrLf & vbCrLf & _
"Please contact Synergy Customer Service with any questions
concerning this order." & vbCrLf & _
"716-834-4457" & vbCrLf & vbCrLf & _
"Thank you for your business!" & vbCrLf & vbCrLf & vbCrLf &
vbCrLf & _
"See Attachment for price confirmation!"
strMessage = strMessage & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf &
vbCrLf & vbCrLf & vbCrLf & vDisclaimer
DoCmd.SendObject acSendReport, "OrderConfirmation", acFormatTXT,
vSendTo, , vBCcTo, strSubject, strMessage, vPreview
[ordConfEmailed] = True
'MsgBox "Email Sent!"
Case 2 'Fax Confirmation
Case Else 'Abort
MsgBox "No method of sending was defined in the Customer Profile for " &
[ordCustName]
End Select
exit_Section:
On Error Resume Next
Set rsProds = Nothing
Set rsCust = Nothing
Set dbs = Nothing
Exit Sub
error_Section:
MsgBox "Error " & Err & " has occured: " & Err.Description
Resume exit_Section
This is among the myriad of problems I have encountered since linking to SQL
Server Tables. The following snippet shows the method then flagging the
email as being sent. Outlook 2000 is the Client and server.
DoCmd.SendObject acSendReport, "OrderConfirmation", acFormatTXT, vSendTo, ,
vBCcTo, strSubject, strMessage, vPreview
[ordConfEmailed] = True
The entire method is below: Sometimes the email does not get sent, and no
error is generated, then it gets marked as being sent. This is a problem
for my client becuase they they can't take the time to call clients to see
if they received their confirmations.
Does anyone have any ideas on this???
Thanks and God Bless,
Mark A. Sam
On Error GoTo error_Section
'Check whether email has been sent for this order
If [ordConfEmailed] = True Then
If MsgBox("An Email has been sent for this order. Do you wish to resend
this confirmation?", vbYesNo + vbDefaultButton2) = vbNo Then
Exit Sub
End If
End If
Dim dbs As Database
Dim rsProds As Recordset
Dim rsCust As Recordset
Dim strCriteria As String
Dim vPreview As Boolean 'used to set the EditMessage argument for the
SendObject method
Dim vSendTo As String 'Used to set the recipient email addy for the
SendObject method
Dim vBCcTo As String 'Used to set the Blind CC for the SendObject method
Dim vDisclaimer As String
Set dbs = CurrentDb()
Set rsCust = dbs.OpenRecordset("Customers", dbOpenDynaset, dbSeeChanges)
Set rsProds = [ Products].Form.RecordsetClone
If rsProds.RecordCount = 0 Then 'If there are no products then the
confirmation isn't nesessary
MsgBox "There are no products entered in this order. Confirmation is
aborted."
Exit Sub
End If
'Determine if this is an Email or Fax send
strCriteria = "[CustID] = " & [ordCustID]
rsCust.FindFirst strCriteria
If rsCust.NoMatch Then
MsgBox "Customer Not Found. You must enter email address manually!"
[ViewEmail] = True
End If
Select Case rsCust![ConfMode]
Case 1 'Email Confirmation
' Redo***
vPreview = [ViewEmail] 'View email is a checkbox on the current form
vSendTo = Nz(rsCust![ConfEmail], "")
If IsNull(vSendTo) Or vSendTo = "" Then
MsgBox "No Confiramtion Email Address was set up for this customer.
You must enter email address manually!"
vPreview = True
End If
vBCcTo = "(e-mail address removed)"
vDisclaimer = "Merchandise covered by this confirmation is warranted to
be free from defects in workmanship " & _
"but not for any specific length of time, type or measure
of service. Claims for allowance will only " & _
"be recognized when presented in writing within 5 days of
receipt of material. No claims for labor, " & _
"transportation or consequential damages will be allowed.
The maximum liability for any claim predicated upon " & _
"defective merchandise is limited to replacement of
merchandise, or to repayment of the purchase price, " & _
"whichever may be elected by Synergy Tooling Systems,
Inc."
Dim strLineItems As String 'This is to hold the line item values from
the [ Products] subform
Dim vQty As String
Dim vPrice As String
Dim vExt As String
Dim vOrdTotal As String
'Create Email Subject line
Dim strSubject As String
strSubject = "Synergy Order Confirmation: " & [ordJob] & " PO: " &
[ordPO] & " Ref#: " & [ordCustRef]
'Create Email message
Dim strMessage As String
If Not IsNull(rsCust![ConfContact]) Then
strMessage = rsCust![ConfContact] & vbCrLf 'This is the first line
of the Message. If you move this you must remove the Null assignment below
Else
strMessage = ""
End If
strMessage = strMessage & [ordCustName] & vbCrLf & _
"PO Number: " & [ordPO] & vbCrLf & _
"Ref # " & [ordCustRef] & vbCrLf & _
"Required Date: " & [ordReqDate] & vbCrLf & _
"Synergy Order Number: " & [ordJob]
strLineItems = String(70, "-") & vbCrLf
strLineItems = strLineItems & "Qty" & Space(4) & "Description" &
Space(27) & "Price Ea " & "Total Price" & vbCrLf
strLineItems = strLineItems & String(70, "-") & vbCrLf
rsProds.MoveFirst
Do Until rsProds.EOF
vQty = Format(rsProds![detQty], "##0")
vPrice = Format(rsProds![detPrice], "#,0.00") '00
vExt = Format(rsProds![detExt], "#,0.00") '00
If Len(vExt) = 4 Then 'Adjust position of extention according to size
strLineItems = strLineItems & vQty & Space(7 - Len(vQty)) &
rsProds![detProdDescription] & Space(38 - Len(rsProds![detProdDescription]))
& Space(8 - Len(vPrice)) & vPrice & Space(18 - Len(vPrice) - (8 -
Len(vPrice))) & vExt & vbCrLf
ElseIf Len(vExt) = 5 Then 'Adjust position of extention according to
size
strLineItems = strLineItems & vQty & Space(7 - Len(vQty)) &
rsProds![detProdDescription] & Space(38 - Len(rsProds![detProdDescription]))
& Space(8 - Len(vPrice)) & vPrice & Space(17 - Len(vPrice) - (8 -
Len(vPrice))) & vExt & vbCrLf
ElseIf Len(vExt) = 6 Then
strLineItems = strLineItems & vQty & Space(7 - Len(vQty)) &
rsProds![detProdDescription] & Space(38 - Len(rsProds![detProdDescription]))
& Space(8 - Len(vPrice)) & vPrice & Space(16 - Len(vPrice) - (8 -
Len(vPrice))) & vExt & vbCrLf
ElseIf Len(vExt) = 8 Then
strLineItems = strLineItems & vQty & Space(7 - Len(vQty)) &
rsProds![detProdDescription] & Space(38 - Len(rsProds![detProdDescription]))
& Space(8 - Len(vPrice)) & vPrice & Space(14 - Len(vPrice) - (8 -
Len(vPrice))) & vExt & vbCrLf
ElseIf Len(vExt) = 9 Then
strLineItems = strLineItems & vQty & Space(7 - Len(vQty)) &
rsProds![detProdDescription] & Space(38 - Len(rsProds![detProdDescription]))
& Space(8 - Len(vPrice)) & vPrice & Space(13 - Len(vPrice) - (8 -
Len(vPrice))) & vExt & vbCrLf
Else
strLineItems = strLineItems & vQty & Space(7 - Len(vQty)) &
rsProds![detProdDescription] & Space(38 - Len(rsProds![detProdDescription]))
& Space(8 - Len(vPrice)) & vPrice & Space(16 - Len(vPrice) - (8 -
Len(vPrice))) & vExt & vbCrLf
End If
rsProds.MoveNext
Loop
vOrdTotal = Format([ Products].Form![Text5], "#,0.00") '00
strLineItems = strLineItems & Space(58) & String(9, "_") & vbCrLf
If Len(vOrdTotal) = 5 Then 'Adjust position of Total according to size
strLineItems = strLineItems & Space(62) & vOrdTotal
ElseIf Len(vOrdTotal) = 6 Then 'Adjust position of Total according to
size
strLineItems = strLineItems & Space(61) & vOrdTotal
'ElseIf Len(vOrdTotal) = 7 Then There is no case for 7 which is the
comma
'strLineItems = strLineItems & Space(59) & vOrdTotal
ElseIf Len(vOrdTotal) = 8 Then
strLineItems = strLineItems & Space(59) & vOrdTotal
ElseIf Len(vOrdTotal) = 9 Then
strLineItems = strLineItems & Space(57) & vOrdTotal
Else
strLineItems = strLineItems & Space(62) & vOrdTotal
End If
'strMessage = strMessage & vbCrLf & strLineItems & vbCrLf & _ (Line
items omitted from email body)
strMessage = strMessage & vbCrLf & vbCrLf & _
"Please contact Synergy Customer Service with any questions
concerning this order." & vbCrLf & _
"716-834-4457" & vbCrLf & vbCrLf & _
"Thank you for your business!" & vbCrLf & vbCrLf & vbCrLf &
vbCrLf & _
"See Attachment for price confirmation!"
strMessage = strMessage & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf &
vbCrLf & vbCrLf & vbCrLf & vDisclaimer
DoCmd.SendObject acSendReport, "OrderConfirmation", acFormatTXT,
vSendTo, , vBCcTo, strSubject, strMessage, vPreview
[ordConfEmailed] = True
'MsgBox "Email Sent!"
Case 2 'Fax Confirmation
Case Else 'Abort
MsgBox "No method of sending was defined in the Customer Profile for " &
[ordCustName]
End Select
exit_Section:
On Error Resume Next
Set rsProds = Nothing
Set rsCust = Nothing
Set dbs = Nothing
Exit Sub
error_Section:
MsgBox "Error " & Err & " has occured: " & Err.Description
Resume exit_Section