So I have finally been able to get this to work right.
I used the above mentioned tool to convert the C# to VB, and andrews code didn't quite work.
So this is what worked for me in VB of course, first off I ended up not using andrews step 1, step 2, or step 3. The process is already built into the code.
The only file that needs to be modified is the maintenance file. And as I am posting the only thing that I have not tested is to get it to run daily.
By default it will run every hour, which makes it easier for testing.
So I modified the hourly maintenance timer to this,
Public Shared Sub HourlyMaintenanceTimer(ByVal state As Object)
CheckAdExpirations()
ProcessSummaryNotification()
CheckAdsToExpire()
End Sub
And then I added this to the maintenance file
Private Shared Sub NotifyMemberByMail(ByVal title As String, ByVal recipientEmail As String, ByVal address As String, ByVal location As String, ByVal categoryname As String, ByVal id As String, ByVal membername As String)
Dim s As SiteSettings = SiteSettings.GetSharedSettings()Dim messageBody As New StringBuilder()
messageBody.AppendLine()
messageBody.Append("RE: Detelli Property Network Listing " + ClassifiedsHttpApplication.SiteUrl)messageBody.AppendFormat("ShowAd.aspx?id={0}", id)
messageBody.AppendLine()
messageBody.AppendLine()
messageBody.AppendLine("Dear " + membername + ",")
messageBody.AppendLine()
messageBody.AppendLine("Thank you for listing your property with Detelli Property Network.")messageBody.AppendLine("This message has been sent to inform you that your listing is about to expire.")
messageBody.AppendLine()
messageBody.AppendLine("Your Listing will expire on " + DateTime.Today.AddDays(1))
messageBody.AppendLine()
messageBody.AppendLine(title)
messageBody.AppendLine(address)
messageBody.AppendLine(location + ", " + categoryname)
messageBody.AppendLine()
messageBody.AppendLine("To extend your listing, Please click the link below.")
messageBody.AppendLine()
messageBody.Append(ClassifiedsHttpApplication.SiteUrl)
messageBody.AppendFormat("EditAd.aspx?id={0}", id)
messageBody.AppendLine()
messageBody.AppendLine()
messageBody.AppendLine("Or log on to www.detelli.com and go to the 'my detelli' page and choose edit listing.")
messageBody.AppendLine()
TryDim m As New MailMessage(s.SiteEmailFromField, recipientEmail)
m.Subject =
"Your property listing will expire Soon"
m.Body = messageBody.ToString()
Dim client As New SmtpClient()
' uncomment this code for ssl enabled smtp servers
' client.EnableSsl = true;
client.Send(m)
Catch ex As Exception
End Try
End Sub
And lastly this
Private Shared Sub CheckAdsToExpire()
Dim ads As AdsDataComponent.AdsDataTable = NothingUsing db As New AdsDataAdapter()
Dim expiration As DateTime = DateTime.Now.AddDays(1)ads = db.GetExpiredAds(expiration, CInt(AdStatus.Activated))
Dim ad As AdsDataComponent.AdsRowFor Each ad In ads.RowsDim member As MembershipUser = Membership.GetUser(ad.MemberName)
NotifyMemberByMail(ad.Title, member.Email, ad.Address, ad.Location, ad.CategoryName, ad.Id, ad.MemberName)
Next ad
End Using
End SubEnd Class
I'll find out at midnight tonight if the if statement in the hourlymaintenancetimer will work or not.
If DateTime.Now.Hour = 0 Then
CheckAdsToExpire()
End If
If that works properly it will only run CheckAdsToExpire once a day, and if not I will post a fix for it.
Also note my modifications to NotifyMembersByEmail I have added to my database suchas Address, so if you do not have, or want address in the email you will have to delete it there and in the last entry.
I just thought a lot of other users could benefit from my work.
Good Luck to all.
Daniel Meis
Please remember to click “Mark as Answer” on the post that helps you.
This can be beneficial to other community members reading the thread.