This topic is locked

Don't send empty fields in email

1/3/2009 4:11:03 PM
ASPRunnerPro General questions
J
JimSmiley author

In follow-up to a previous post:
I'm using the following code to send a message to myself when a new record is created.
*****

Dim dkeys

message =""
dkeys = dict.keys

For n = 0 To dict.Count-1
Next
message = message & vbcrlf & "Purchase Order Number:" & dict("PONumber") & vbcrlf

message = message & vbcrlf & "Order Date" & ": " & dict("OrderDate") & vbcrlf

message = message & vbcrlf & "Bill to:" & vbcrlf & dict("BillingInfo") & vbcrlf

message = message & vbcrlf & "Ship to:" & vbcrlf & dict("ShippingInfo") & vbcrlf

message = message & vbcrlf & "Contact:" & dict("ContactName") & vbcrlf

message = message & vbcrlf & "Telephone:" & dict("ContactPhone") & vbcrlf

message = message & vbcrlf & "Email:" & dict("ContactEmail") & vbcrlf
email="me@mycompany.com"

subject="New PO Submitted"
sendmail email, subject, message

*

How do I send only the fields that have data?

J
Jane 1/6/2009

Hi,
here is a sample:

...

if dict("PONumber")<>"" and dict("PONumber")<>0 then

message = message & vbcrlf & "Purchase Order Number:" & dict("PONumber") & vbcrlf

end if

if dict("OrderDate")<>"" and dict("OrderDate")<>0 then

message = message & vbcrlf & "Order Date" & ": " & dict("OrderDate") & vbcrlf

end if

message = message & vbcrlf & "Bill to:" & vbcrlf & dict("BillingInfo") & vbcrlf

message = message & vbcrlf & "Ship to:" & vbcrlf & dict("ShippingInfo") & vbcrlf

message = message & vbcrlf & "Contact:" & dict("ContactName") & vbcrlf

message = message & vbcrlf & "Telephone:" & dict("ContactPhone") & vbcrlf

message = message & vbcrlf & "Email:" & dict("ContactEmail") & vbcrlf

...

J
JimSmiley author 1/7/2009

Jane;
Thanks for the reply but unfortunately it causes the email not to be sent. I am using it in this manner:
[codebox]message = message & vbcrlf & "Deactivation Basket:" & dict("DeactivationBasket") & vbcrlf

message = message & vbcrlf & "Pest Booklet:" & dict("BugBook") & vbcrlf

if dict("BugChart")<>"" and dict("BugChart")<>0 then

message = message & vbcrlf & "Pest Chart:" & dict("BugChart") & vbcrlf

end if

message = message & vbcrlf & "Comments:" & vbcrlf & dict("Comments") & vbcrlf[/codebox]
Am I doing something incorrectly?

J
Jane 1/8/2009

Hi,
It's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.