Email creation is extremely slow

Seb

Registered User.
Local time
Today, 16:15
Joined
Jun 20, 2006
Messages
55
Hi All

Probably a simple one but for some reason, this takes around 30 seconds to open an email.....not sure why as the information is pretty basic and not like its running very labor intensive queries???

Here's the code I'm using....please dont criticise it just yet...its still a work in progress:

Private Sub Command42_Click()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim sSQL As String
Dim sSQL2 As String

sSQL = "SELECT * FROM tblItems where quotenumber =" & Me!txtQuoteNum
sSQL2 = "SELECT * FROM tblPricing where quotenumber =" & Me!txtQuoteNum
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(sSQL, dbOpenSnapshot)


If Not rst.BOF Then rst.MoveFirst
Do Until rst.EOF
strTable = strTable & rst!ItemDescr & ". Dimensions: (" & rst!Length & "x" & rst!Width & "x" & rst!Height & ") - " & rst!Weight & "Kg" & vbNewLine
rst.MoveNext
Loop
Set rst = Nothing
Set rst = dbs.OpenRecordset(sSQL2, dbOpenSnapshot)
If Not rst.BOF Then rst.MoveFirst
Do Until rst.EOF
strTable2 = strTable2 & rst!PricingDetail & " - $" & rst!Price & vbNewLine
rst.MoveNext
Loop
Set rst = Nothing
If Me.txtContact = "" Then
Me.txtContact.Value = "Sir / Madam"
End If
strBody = "Dear " & Me.txtContact & vbNewLine
strBody = strBody & "Thank you for requesting a quotation through *** Transport." & vbNewLine & vbNewLine
strBody = strBody & "Based on the information provided, your quotation is as follows: " & vbNewLine & vbNewLine
strBody = strBody & "From: " & Me.Pickup & vbNewLine & vbNewLine
strBody = strBody & "To: " & Me.Deliver & vbNewLine & vbNewLine
strBody = strBody & "Items being moved: " & vbNewLine
strBody = strBody & strTable & vbNewLine & vbNewLine
strBody = strBody & "Based on this information, your quoted price is: " & vbNewLine & strTable2 & vbNewLine
strBody = strBody & "Total: " & Me.txtPriceTotal



strTo = Me!txtEmail
DoCmd.SendObject , , acFormatRTF, strTo, , , "Here's your Quote", strBody, True

 
Find out what parts are slow. Put 'Debug.Print Now()' statements in everywhere and see what takes the longest.
I bet your send object command takes a while, since it has to open your email program, and then your RTF format is not the quickest.
Things I'd try: 1) Open your email program first, then run your code, 2) HTML format.
 

Users who are viewing this thread

Back
Top Bottom