Line 1: Imports Microsoft.VisualBasic
Line 2: Imports System
Line 3: Imports System.IO
Line 4: Imports System.Data
Line 5: Imports System.Configuration
Line 6: Imports System.Web
Line 7: Imports System.Web.Security
Line 8: Imports System.Web.UI
Line 9: Imports System.Web.UI.WebControls
Line 10: Imports System.Web.UI.WebControls.WebParts
Line 11: Imports System.Web.UI.HtmlControls
Line 12: Imports Commerce.Common
Line 13: Imports Commerce.Messaging
Line 14: Imports Commerce.ContentManagement
Line 15: Imports System.Net.Mail
Line 16: Imports Twilio
Line 17: Imports Twilio.Rest.Api.V2010.Account
Line 18:
Line 19: ' <summary>
Line 20: ' Summary description for MessagingController
Line 21: ' </summary>
Line 22: Public Class MessagingController
Line 23: ' <summary>
Line 24: ' This method can be used for all kinds of fun things - like dropping an EDI x12 document, or an
Line 25: ' XML message for BizTalk. For instance, you can serialize down an order simply by using
Line 26: ' order.ToXML(), put that string into a document (it's well-formatted XML already), and
Line 27: ' drop it on an FTP server.
Line 28: ' </summary>
Line 29: ' <param name="absoluteFilePath">The path to the file to send</param>
Line 30: ' <param name="ftpServerUrl">should be something like ftp://servername.com/directory</param>
Line 31: ' <param name="userName">FTP username</param>
Line 32: ' <param name="password">FTP password</param>
Line 33: Private Sub New()
Line 34: End Sub
Line 35: Public Shared Sub SendFTP(ByVal absoluteFilePath As String, ByVal ftpServerUrl As String, ByVal userName As String, ByVal password As String)
Line 36:
Line 37: FTPClient.PutFile(absoluteFilePath, ftpServerUrl, userName, password)
Line 38: End Sub
Line 39:
Line 40:
Line 41: Private Function URLEncode(ByVal s As String) As String
Line 42: s = Replace(s, "%", "%25")
Line 43: s = Replace(s, "$", "%24")
Line 44: s = Replace(s, "&", "%26")
Line 45: s = Replace(s, "+", "%2B")
Line 46: s = Replace(s, ",", "%2C")
Line 47: s = Replace(s, "/", "%2F")
Line 48: s = Replace(s, ":", "%3A")
Line 49: s = Replace(s, ";", "%3B")
Line 50: s = Replace(s, "=", "%3D")
Line 51: s = Replace(s, "?", "%3F")
Line 52: s = Replace(s, "@", "%40")
Line 53: s = Replace(s, " ", "%20")
Line 54: URLEncode = s
Line 55: End Function
Line 56:
Line 57:
Line 58: Public Enum Message As Integer
Line 59: OrderReceivedEmail = 1
Line 60: MailerToCustomer = 2
Line 61: ShippingNotification = 4
Line 62: OrderCancellations = 12
Line 63: OrderRefunded = 13
Line 64:
Line 65: ShippingNotification_Customer = 3
Line 66: OrderCancellation_Customer = 4
Line 67: OrderRefund_Customer = 5
Line 68: End Enum
Line 69: Public Shared Function GetRandom(ByVal Min As Integer, ByVal Max As Integer) As Integer
Line 70: ' by making Generator static, we preserve the same instance '
Line 71: ' (i.e., do not create new instances with the same seed over and over) '
Line 72: ' between calls '
Line 73: Static Generator As System.Random = New System.Random()
Line 74: Return Generator.Next(Min, Max)
Line 75: End Function
Line 76:
Line 77: ' <summary>
Line 78: ' This method will send a message to the shop owner, notifying them of a new order
Line 79: ' </summary>
Line 80: ' <param name="order">The order itself</param>
Line 81: ' <returns></returns>
Line 82: Public Shared Function SendMerchantOrderNotice(ByVal order As Order) As Boolean
Line 83:
Line 84: Try
Line 85: If HttpContext.Current.Application("mail_sms").length < 12 Then
Line 86: HttpContext.Current.Application("mail_sms") = "1"
Line 87: End If
Line 88: Catch
Line 89: HttpContext.Current.Application("mail_sms") = "1"
Line 90: End Try
Line 91:
Line 92: Try
Line 93: If HttpContext.Current.Application("companyphone").length < 12 Then
Line 94: HttpContext.Current.Application("companyphone") = "1"
Line 95: End If
Line 96: Catch
Line 97: HttpContext.Current.Application("companyphone") = "1"
Line 98: End Try
Line 99:
Line 100: Try
Line 101: If HttpContext.Current.Application("fax_problem").length <= 0 Then
Line 102: HttpContext.Current.Application("fax_problem") = "0"
Line 103: End If
Line 104: Catch
Line 105: HttpContext.Current.Application("fax_problem") = "0"
Line 106: End Try
Line 107:
Line 108: Try
Line 109: If HttpContext.Current.Application("fax_good").length <= 0 Then
Line 110: HttpContext.Current.Application("fax_good") = "14569"
Line 111: End If
Line 112: Catch
Line 113: HttpContext.Current.Application("fax_good") = "14569"
Line 114: End Try
Line 115:
Line 116:
Line 117:
Line 118:
Line 119: Dim pdf As MemoryStream = New MemoryStream()
Line 120: 'dim pdf As New PdfDocument()
Line 121: pdf = order.GeneratePDF()
Line 122: Dim bOut As Boolean = False
Line 123: Dim template As String = Utility.GetFileText("MailerTemplates/MailerToMerchant.txt")
Line 124:
Line 125: 'get the mailer from the DB
Line 126: Dim mailerID As Integer = Convert.ToInt16(Message.OrderReceivedEmail)
Line 127: Dim mailer As Email = New Email(mailerID)
Line 128: Dim sMessage As String = template
Line 129: Dim mailer2 As New MailMessage
Line 130:
Line 131:
Line 132:
Line 133: Dim faxfromdb As String = "0"
Line 134: Try
Line 135: Dim bkf As TextEntry = New TextEntry("currentfax")
Line 136: faxfromdb = bkf.ToString
Line 137: Catch
Line 138: End Try
Line 139:
Line 140: pdf.Position = 0
Line 141: mailer2.IsBodyHtml = False
Line 142: Dim srcBt2 As Byte()
Line 143: Dim encodedBase642 As String
Line 144: ReDim srcBt2(pdf.Length)
Line 145: srcBt2 = pdf.ToArray()
Line 146: encodedBase642 = System.Convert.ToBase64String(srcBt2)
Line 147:
Line 148: Dim NC, NC2 As New System.Collections.Specialized.NameValueCollection
Line 149:
Line 150: NC2.Add("operation", "sendfax")
Line 151: NC2.Add("faxno", ConfigurationManager.AppSettings("faxnumber"))
Line 152: NC2.Add("faxfilenames[0]", "order.pdf")
Line 153: NC2.Add("faxfiledata[0]", encodedBase642)
Line 154: 'NC.Add("faxurl", Utility.GetSiteRoot() & "/receipt2.aspx?t=" & order.orderGuid)
Line 155: NC2.Add("em_notify", "1")
Line 156:
Line 157:
Line 158: Dim address2 As String = "https://api.faxage.com/httpsfax.php"
Line 159: Dim client2 As System.Net.WebClient = New System.Net.WebClient()
Line 160:
Line 161: Dim RESP2 As Byte()
Line 162: Dim R2 As String
Line 163: Dim faxroute As String ="0"
Line 164: if ConfigurationManager.AppSettings("currentfax") > "0"
Line 165: If HttpContext.Current.Application("fax_problem").indexof(ConfigurationManager.AppSettings("currentfax")) < 0 Then
Line 166: faxroute = ConfigurationManager.AppSettings("currentfax")
Line 167: Else
Line 168: faxroute = HttpContext.Current.Application("fax_good").substring(GetRandom(0, HttpContext.Current.Application("fax_good").length), 1)
Line 169: End If
Line 170: end if
Line 171:
Line 172:
Line 173: Select Case faxroute
Line 174: Case "0" 'no fax
Line 175:
Line 176: Case "1" 'faxage
Line 177: NC2.Add("username", "drinkeatlive")
Line 178: NC2.Add("company", "17901")
Line 179: NC2.Add("password", "C$0k@13881")
Line 180: RESP2 = client2.UploadValues(address2, NC2)
Line 181: R2 = System.Text.Encoding.ASCII.GetString(RESP2)
Line 182: If R2.IndexOf("JOBID") < 0 Then
Line 183: 'HttpContext.Current.Response.Redirect("error.aspx?err=sendfax" + R2.Substring(0, 6))
Line 184: End If
Line 185: Case "2" 'faxage
Line 186: NC2.Add("username", "johnsu99")
Line 187: NC2.Add("company", "22759")
Line 188: NC2.Add("password", "C$0k@13882")
Line 189: RESP2 = client2.UploadValues(address2, NC2)
Line 190: R2 = System.Text.Encoding.ASCII.GetString(RESP2)
Line 191: If R2.IndexOf("JOBID") < 0 Then
Line 192: 'HttpContext.Current.Response.Redirect("error.aspx?err=sendfax" + R2.Substring(0, 6))
Line 193: End If
Line 194: Case "3" 'faxage
Line 195: NC2.Add("username", "johnsu3")
Line 196: NC2.Add("company", "29387")
Line 197: NC2.Add("password", "C$0k@13882")
Line 198: RESP2 = client2.UploadValues(address2, NC2)
Line 199: R2 = System.Text.Encoding.ASCII.GetString(RESP2)
Line 200: If R2.IndexOf("JOBID") < 0 Then
Line 201: 'HttpContext.Current.Response.Redirect("error.aspx?err=sendfax" + R2.Substring(0, 6))
Line 202: End If
Line 203: Case "4" 'vitelity
Line 204: NC.Add("login", "suj9_suj9_01")
Line 205: NC.Add("cmd", "sendfax")
Line 206: NC.Add("pass", "P2ssw0rd")
Line 207:
Line 208: NC.Add("faxnum", ConfigurationManager.AppSettings("faxnumber"))
Line 209: NC.Add("faxsrc", "7188892513")
Line 210: NC.Add("recname", ConfigurationManager.AppSettings("companyOrderIdentifier"))
Line 211: NC.Add("file1", "Vorder.pdf")
Line 212: NC.Add("data1", encodedBase642)
Line 213:
Line 214: address2 = "http://api.vitelity.net/fax.php"
Line 215: RESP2 = client2.UploadValues(address2, NC)
Line 216: R2 = System.Text.Encoding.ASCII.GetString(RESP2)
Line 217: 'HttpContext.Current.Response.Redirect(r)
Line 218: If R2.IndexOf("ok:") < 0 Then
Line 219: HttpContext.Current.Response.Redirect("error_order.htm?err=emailyoufax" + R2)
Line 220: End If
Line 221:
Line 222: Case "5" 'rcfax
Line 223: ' Dim filereader As New IO.FileStream(stringf, IO.FileMode.Open)
Line 224: mailer2.Attachments.Add(New Attachment(pdf, "Faxorder.pdf"))
Line 225: mailer2.To.Add(New MailAddress(ConfigurationManager.AppSettings("faxnumber").ToString & "@rcfax.com"))
Line 226: ' mailer2.To.add(New MailAddress("drinkeatlive@gmail.com"))
Line 227: Dim objSMTP As New SmtpClient
Line 228: Try
Line 229: objSMTP.Send(mailer2)
Line 230: Catch
Line 231: End Try
Line 232:
Line 233: Case "6" 'rapidfax email, pdf
Line 234: ' Dim filereader As New IO.FileStream(stringf, IO.FileMode.Open)
Line 235:
Line 236: mailer2.Attachments.Add(New Attachment(pdf, "Faxorder.pdf"))
Line 237: mailer2.To.Add(New MailAddress(ConfigurationManager.AppSettings("faxnumber").ToString & "@rapidfax.com"))
Line 238: 'mailer2.To.Add(New MailAddress("drinkeatlive@gmail.com"))
Line 239: Dim objSMTP As New SmtpClient
Line 240: Try
Line 241: objSMTP.Send(mailer2)
Line 242: Catch
Line 243: End Try
Line 244:
Line 245: Case "7" 'faxage email, pdf
Line 246: ' Dim filereader As New IO.FileStream(stringf, IO.FileMode.Open)
Line 247: mailer2.Attachments.Add(New Attachment(pdf, "Faxorder.pdf"))
Line 248: mailer2.To.Add(New MailAddress(ConfigurationManager.AppSettings("faxnumber").ToString & "@faxage.com"))
Line 249: ' mailer2.To.add(New MailAddress("drinkeatlive@gmail.com"))
Line 250: Dim objSMTP As New SmtpClient
Line 251: Try
Line 252: objSMTP.Send(mailer2)
Line 253: Catch
Line 254: End Try
Line 255: Case "8" 'vitelity email, pdf
Line 256: ' Dim filereader As New IO.FileStream(stringf, IO.FileMode.Open)
Line 257: mailer2.Attachments.Add(New Attachment(pdf, "Faxorder.pdf"))
Line 258: mailer2.To.Add(New MailAddress(ConfigurationManager.AppSettings("faxnumber").ToString & "@emailyourfax.com"))
Line 259: ' mailer2.To.add(New MailAddress("drinkeatlive@gmail.com"))
Line 260: mailer2.Subject = "7188892513"
Line 261: Dim objSMTP As New SmtpClient
Line 262: Try
Line 263: objSMTP.Send(mailer2)
Line 264: Catch
Line 265: End Try
Line 266: Case "9" 'other fax email, pdf
Line 267: ' Dim filereader As New IO.FileStream(stringf, IO.FileMode.Open)
Line 268: mailer2.Attachments.Add(New Attachment(pdf, "Faxorder.pdf"))
Line 269: mailer2.To.Add(New MailAddress(ConfigurationManager.AppSettings("faxnumber").ToString & "@" & ConfigurationManager.AppSettings("fax9")))
Line 270: ' mailer2.To.add(New MailAddress("drinkeatlive@gmail.com"))
Line 271: Dim objSMTP As New SmtpClient
Line 272: Try
Line 273: objSMTP.Send(mailer2)
Line 274: Catch
Line 275: End Try
Line 276: End Select
Line 277:
Line 278: 'we're overriding the DB templates
Line 279: 'use the text template
Line 280: 'it's formatted nicely
Line 281:
Line 282: If template.Length > 0 Then
Line 283: 'run some tag replacements. First with the name
Line 284:
Line 285: 'sMessage = sMessage.Replace("#NAME#", order.FirstName )
Line 286:
Line 287: 'ordernumber
Line 288: sMessage = sMessage.Replace("#ORDER#", order.ToHtml_admin_fax)
Line 289:
Line 290: 'tagline
Line 291: 'sMessage = sMessage.Replace("#TAGLINE#", "The Commerce Starter Kit: Sell Your Bits, Not Your Soul")
Line 292:
Line 293: 'items
Line 294: sMessage = sMessage.Replace("#LINK#", Utility.GetSiteRoot() & "/admin/admin_orders.aspx?id=" & order.OrderID)
Line 295:
Line 296: 'setup the mailer
Line 297: Dim mlist As String = ConfigurationManager.AppSettings("manager_email_list")
Line 298:
Line 299: mailer.Subject = HttpContext.Current.Application("fax_problem") + " " + faxroute + " " + ConfigurationManager.AppSettings("faxnumber") + " " + ConfigurationManager.AppSettings("companyOrderIdentifier") + " Order from " & order.FirstName
Line 300: mailer.MessageBody = sMessage
Line 301:
Line 302: mailer.ToList = mlist
Line 303: ' mailer.FromEmail = "order@menucities.com"
Line 304: mailer.CcList = ""
Line 305: 'send it off!
Line 306: Dim maillist As String()
Line 307: maillist = mailer.ToList.Split(";")
Line 308: Dim tomail As String
Line 309: For Each tomail In maillist
Line 310: mailer.ToList = tomail
Line 311: Try
Line 312: bOut = Email.SendEmail(mailer)
Line 313: Catch
Line 314: End Try
Line 315: Next
Line 316: If ConfigurationManager.AppSettings("mail_sms").ToString.Length = 11 Then
Line 317: mailer.Subject = "New Order From "
Line 318: mailer.MessageBody = "New Order Phone#:" & order.Email
Line 319: mailer.ToList = ConfigurationManager.AppSettings("mail_sms")
Line 320: mailer.FromEmail = ConfigurationManager.AppSettings("manager_email")
Line 321: maillist = mailer.ToList.Split(";")
Line 322: For Each tomail In maillist
Line 323: mailer.ToList = tomail
Line 324: Try
Line 325: bOut = Email.SendEmail(mailer)
Line 326: Catch
Line 327: End Try
Line 328: Next
Line 329:
Line 330: End If
Line 331:
Line 332: End If
Line 333:
Line 334: If ConfigurationManager.AppSettings("companyphone").ToString.Length = 12 Then
Line 335: try
Line 336: Dim accountSid As String = "9b19fc76-1c8b-460b-a110-094ca1dacfec"
Line 337: Dim authToken As String = HttpContext.Current.application("7896tyl")&"9ed97"
Line 338: TwilioClient.Init(accountSid, authToken, New Dictionary(Of String, Object) From {
Line 339: {"signalwireSpaceUrl", "menucities.signalwire.com"}
Line 340: })
Line 341: Dim [call] = CallResource.Create(url:=New Uri("https://menucities.signalwire.com/laml-bins/02e8f9f3-f09e-4cd2-b72c-121d4fa48ce7"), [to]:=New Types.PhoneNumber(ConfigurationManager.AppSettings("companyphone").ToString), from:=New Types.PhoneNumber("+15162698781"))
Line 342: catch
Line 343: end try
Line 344:
Line 345: End If
Line 346:
Line 347: If ConfigurationManager.AppSettings("mail_sms").ToString.Length = 12 Then
Line 348: try
Line 349: Dim accountSid As String = "9b19fc76-1c8b-460b-a110-094ca1dacfec"
Line 350: Dim authToken As String = HttpContext.Current.application("7896tyl")&"9ed97"
Line 351: TwilioClient.Init(accountSid, authToken, New Dictionary(Of String, Object) From {
Line 352: {"signalwireSpaceUrl", "menucities.signalwire.com"}
Line 353: })
Line 354: Dim msg As String
Line 355: msg = Utility.GetSiteRoot() & "/receipt.aspx?t=" & order.OrderGUID & " phone " & order.Email
Line 356: if order.lastname.length>16 then msg=msg & " " & order.LastName
Line 357:
Line 358:
Line 359: Dim [message] = MessageResource.Create(from:=New Types.PhoneNumber("+18778002062"), body:=msg, [to]:=New Types.PhoneNumber(ConfigurationManager.AppSettings("mail_sms").ToString))
Line 360:
Line 361: catch
Line 362: end try
Line 363: End If
Line 364:
Line 365:
Line 366: Return bOut
Line 367:
Line 368:
Line 369:
Line 370: End Function
Line 371: ' <summary>
Line 372: ' This is an overriden method of the Mailer class. The default message in the DB is going
Line 373: ' to be overwritten with a nicely formatted HTML message stored in the EmailTemplates
Line 374: ' Directory. Feel free to change as needed.
Line 375: ' </summary>
Line 376: ' <param name="order">The order to send out the mailer for.</param>
Line 377: ' <returns></returns>
Line 378: Public Shared Function SendOrderReceivedEmail(ByVal order As Order) As Boolean
Line 379:
Line 380: Dim bOut As Boolean = False
Line 381:
Line 382: 'get the mailer from the DB
Line 383: Dim mailerID As Integer = Convert.ToInt16(Message.MailerToCustomer)
Line 384: Dim mailer As Email = New Email(mailerID)
Line 385:
Line 386: 'overriding the base DB template
Line 387: 'using a nicely formatted HTML one...
Line 388:
Line 389: 'load up the template
Line 390: 'there is a text template too...
Line 391: Dim template As String = Utility.GetFileText("MailerTemplates/OrderConfirm.htm")
Line 392:
Line 393: If template.Length > 0 Then
Line 394: 'run some tag replacements. First with the name
Line 395: Dim sMessage As String = template
Line 396: sMessage = sMessage.Replace("#NAME#", order.FirstName)
Line 397:
Line 398: 'ordernumber
Line 399: sMessage = sMessage.Replace("#ORDERINFO#", order.ToHtml())
Line 400:
Line 401: 'admin email
Line 402: sMessage = sMessage.Replace("#STOREEMAIL#", "<a href='mailto:" & mailer.FromEmail & "'>" & mailer.FromEmail & "</a>")
Line 403:
Line 404: 'tagline
Line 405: 'sMessage = sMessage.Replace("#TAGLINE#","<b>The Commerce Starter Kit: Sell Your Bits, Not Your Soul</b>")
Line 406:
Line 407: 'link
Line 408: sMessage = sMessage.Replace("#LINK#", "<a href='" & Utility.GetSiteRoot() & "'>Our Website</a>")
Line 409:
Line 410: 'setup the mailer
Line 411: mailer.MessageBody = sMessage
Line 412: mailer.ToList = order.ShippingTrackingNumber
Line 413:
Line 414: mailer.CcList = ""
Line 415: mailer.Subject = ConfigurationManager.AppSettings("companyOrderIdentifier") + " Order Sent"
Line 416: 'send it off!
Line 417: Try
Line 418: bOut = Email.SendEmail(mailer)
Line 419: Catch
Line 420: End Try
Line 421: End If
Line 422: Return bOut
Line 423: End Function
Line 424: Public Shared Function SendRecommandation(ByVal mailfrom As String, ByVal mailto As String, ByVal mailername As String, ByVal prodname As String) As Boolean
Line 425:
Line 426: Dim bOut As Boolean = False
Line 427:
Line 428: 'get the mailer from the DB
Line 429: Dim mailerID As Integer = Convert.ToInt16(Message.MailerToCustomer)
Line 430: Dim mailer As Email = New Email(mailerID)
Line 431: mailer.Subject = ConfigurationManager.AppSettings("companyOrderIdentifier") + " Dish Recommendation from " + mailername
Line 432:
Line 433: 'overriding the base DB template
Line 434: 'using a nicely formatted HTML one...
Line 435:
Line 436: 'load up the template
Line 437: 'there is a text template too...
Line 438: Dim template As String = Utility.GetFileText("../MailerTemplates/recommend.htm")
Line 439:
Line 440: If template.Length > 0 Then
Line 441: 'run some tag replacements. First with the name
Line 442: Dim sMessage As String = template
Line 443: sMessage = sMessage.Replace("#PRODNAME#", prodname)
Line 444:
Line 445: 'ordernumber
Line 446: sMessage = sMessage.Replace("#SENDERNAME#", mailername + " (" + mailfrom + ")")
Line 447:
Line 448: 'admin email
Line 449:
Line 450:
Line 451: 'tagline
Line 452: 'sMessage = sMessage.Replace("#TAGLINE#","<b>The Commerce Starter Kit: Sell Your Bits, Not Your Soul</b>")
Line 453:
Line 454: 'link
Line 455:
Line 456:
Line 457: 'setup the mailer
Line 458: mailer.MessageBody = sMessage
Line 459: mailer.ToList = "suj99@yahoo.com;" + mailto
Line 460:
Line 461:
Line 462: 'send it off!
Line 463: bOut = Email.SendEmail(mailer)
Line 464:
Line 465: End If
Line 466: Return bOut
Line 467: End Function
Line 468: Public Shared Function Sendsuggestion(ByVal rating As Int16, ByVal review As String, ByVal mailername As String, ByVal youremail As String) As Boolean
Line 469:
Line 470: Dim bOut As Boolean = False
Line 471: If review.length <= 80 Then
Line 472: 'get the mailer from the DB
Line 473: Dim mailerID As Integer = Convert.ToInt16(Message.MailerToCustomer)
Line 474: Dim mailer As Email = New Email(mailerID)
Line 475: mailer.Subject = ConfigurationManager.AppSettings("companyOrderIdentifier") + " Customer Suggestion"
Line 476:
Line 477: 'overriding the base DB template
Line 478: 'using a nicely formatted HTML one...
Line 479:
Line 480: 'load up the template
Line 481: 'there is a text template too...
Line 482: Dim template As String = Utility.GetFileText("MailerTemplates/suggestionform.htm")
Line 483:
Line 484: If template.Length > 0 Then
Line 485: 'run some tag replacements. First with the name
Line 486: Dim sMessage As String = template
Line 487: sMessage = sMessage.Replace("#PRODRATE#", rating)
Line 488:
Line 489: 'ordernumber
Line 490: sMessage = sMessage.Replace("#SENDERNAME#", mailername + " (" + youremail + ")")
Line 491: sMessage = sMessage.Replace("#SUGGESTION#", review)
Line 492:
Line 493: 'admin email
Line 494:
Line 495:
Line 496: 'tagline
Line 497: 'sMessage = sMessage.Replace("#TAGLINE#","<b>The Commerce Starter Kit: Sell Your Bits, Not Your Soul</b>")
Line 498:
Line 499: 'link
Line 500:
Line 501:
Line 502: 'setup the mailer
Line 503: mailer.MessageBody = sMessage
Line 504: mailer.ToList = ConfigurationManager.AppSettings("suggestion_email")
Line 505: mailer.CcList = ""
Line 506:
Line 507:
Line 508: 'send it off!
Line 509: Dim maillist As String()
Line 510: maillist = mailer.ToList.split(";")
Line 511: Dim tomail As String
Line 512: For Each tomail In maillist
Line 513: mailer.tolist = tomail
Line 514: bOut = Email.SendEmail(mailer)
Line 515: Next
Line 516:
Line 517: End If
Line 518: End If
Line 519: Return bOut
Line 520: End Function
Line 521:
Line 522: Public Shared Function Sendsuggestion1(ByVal rating As Int16, ByVal review As String, ByVal specialrequest As String, ByVal mailername As String, ByVal youremail As String, ByVal hibachiordining As String) As Boolean
Line 523:
Line 524: Dim bOut As Boolean = False
Line 525:
Line 526: 'get the mailer from the DB
Line 527: Dim mailerID As Integer = Convert.ToInt16(Message.MailerToCustomer)
Line 528: Dim mailer As Email = New Email(mailerID)
Line 529: mailer.Subject = ConfigurationManager.AppSettings("companyOrderIdentifier") + " Customer Reservation " + mailername
Line 530:
Line 531: 'overriding the base DB template
Line 532: 'using a nicely formatted HTML one...
Line 533:
Line 534: 'load up the template
Line 535: 'there is a text template too...
Line 536: Dim template As String = Utility.GetFileText("MailerTemplates/reservation.htm")
Line 537:
Line 538: If template.Length > 0 Then
Line 539: 'run some tag replacements. First with the name
Line 540: Dim sMessage As String = template
Line 541: sMessage = sMessage.Replace("#PRODRATE#", rating)
Line 542: sMessage = sMessage.Replace("#SPECIAL#", specialrequest)
Line 543: 'ordernumber
Line 544: sMessage = sMessage.Replace("#SENDERNAME#", mailername + " (" + youremail + ")")
Line 545: sMessage = sMessage.Replace("#SUGGESTION#", review)
Line 546:
Line 547: 'admin email
Line 548:
Line 549:
Line 550: 'tagline
Line 551: 'sMessage = sMessage.Replace("#TAGLINE#","<b>The Commerce Starter Kit: Sell Your Bits, Not Your Soul</b>")
Line 552:
Line 553: 'link
Line 554:
Line 555:
Line 556: 'setup the mailer
Line 557: mailer.MessageBody = sMessage
Line 558: mailer.ToList = ConfigurationManager.AppSettings("suggestion_email")
Line 559: mailer.CcList = ""
Line 560:
Line 561: 'send it off!
Line 562: dim maillist as string()
Line 563: maillist= mailer.ToList.split(";")
Line 564: dim tomail as string
Line 565: for each tomail in maillist
Line 566: mailer.tolist=tomail
Line 567: bOut = Email.SendEmail(mailer)
Line 568: next
Line 569:
Line 570: End If
Line 571: Return bOut
Line 572: End Function
Line 573:
Line 574: Public Shared Function SendEmai_promotion(ByVal emailto As String, ByVal sbody As String, ByVal ssubject As String, ByVal sfromemail As String, ByVal sfromname As String) As Boolean
Line 575:
Line 576: Dim bOut As Boolean = False
Line 577:
Line 578: 'get the mailer from the DB
Line 579: Dim mailerID As Integer = Convert.ToInt16(Message.MailerToCustomer)
Line 580: Dim mailer As Email = New Email(mailerID)
Line 581: mailer.IsHTML = False
Line 582:
Line 583: 'overriding the base DB template
Line 584: 'using a nicely formatted HTML one...
Line 585:
Line 586: 'load up the template
Line 587: 'there is a text template too...
Line 588: 'Dim template As String = Utility.GetFileText("MailerTemplates/htmlmail.htm")
Line 589:
Line 590: 'If template.Length > 0 Then
Line 591: 'run some tag replacements. First with the name
Line 592: ' Dim sMessage As String
Line 593: '= template
Line 594: 'sMessage = sMessage.Replace("#NAME#", "john" & " " & "su")
Line 595:
Line 596: 'ordernumber
Line 597: 'sMessage = sMessage.Replace("#ORDERINFO#", order.ToHtml())
Line 598:
Line 599: 'admin email
Line 600: 'sMessage = sMessage.Replace("#STOREEMAIL#", "<a href='mailto:" & mailer.FromEmail & "'>" & mailer.FromEmail & "</a>")
Line 601:
Line 602: 'tagline
Line 603: 'sMessage = sMessage.Replace("#TAGLINE#","<b>The Commerce Starter Kit: Sell Your Bits, Not Your Soul</b>")
Line 604:
Line 605: 'link
Line 606: 'sMessage = sMessage.Replace("#LINK#", "<a href='" & Utility.GetSiteRoot() & "'>Our Store</a>")
Line 607:
Line 608: 'setup the mailer
Line 609: mailer.MessageBody = sbody
Line 610: mailer.Subject = ssubject
Line 611: mailer.FromEmail = sfromemail
Line 612: mailer.FromName = sfromname
Line 613: mailer.ToList = emailto
Line 614: mailer.CcList = ""
Line 615:
Line 616:
Line 617: 'send it off!
Line 618: bOut = Email.SendEmail(mailer)
Line 619:
Line 620: 'End If
Line 621: Return bOut
Line 622: End Function
Line 623:
Line 624: Public Shared Function SendShippingNotification_Customer(ByVal order As Order) As Boolean
Line 625: Dim bOut As Boolean = SendMailToCustomer(order, Message.ShippingNotification_Customer)
Line 626: Return bOut
Line 627: End Function
Line 628:
Line 629: Public Shared Function SendOrderCancellation_Customer(ByVal order As Order) As Boolean
Line 630: Dim bOut As Boolean = SendMailToCustomer(order, Message.OrderCancellation_Customer)
Line 631: Return bOut
Line 632: End Function
Line 633:
Line 634: Public Shared Function SendOrderRefund_Customer(ByVal order As Order) As Boolean
Line 635: Dim bOut As Boolean = SendMailToCustomer(order, Message.OrderRefund_Customer)
Line 636: Return bOut
Line 637: End Function
Line 638:
Line 639: Private Shared Function SendMailToCustomer(ByVal order As Order, ByVal message As Message) As Boolean
Line 640: Dim bOut As Boolean = False
Line 641:
Line 642: 'get the mailer from the DB
Line 643: Dim mailer As Email = New Email(Convert.ToInt32(message))
Line 644:
Line 645: Dim template As String = mailer.MessageBody
Line 646: If template.Length > 0 Then
Line 647: 'run the tag replacements
Line 648: template = ReplaceConstantsInMessage(order, template, mailer)
Line 649: 'setup the mailer
Line 650: mailer.MessageBody = template
Line 651: mailer.ToList = order.Email
Line 652: mailer.CcList = mailer.CcList
Line 653:
Line 654: 'send it off!
Line 655: bOut = Email.SendEmail(mailer)
Line 656: End If
Line 657: Return bOut
Line 658: End Function
Line 659:
Line 660: ''' <summary>
Line 661: ''' run some tag replacements. First with the name
Line 662: ''' </summary>
Line 663: ''' <param name="template"></param>
Line 664: ''' <returns></returns>
Line 665: Private Shared Function ReplaceConstantsInMessage(ByVal order As Order, ByVal template As String, ByVal mailer As Email) As String
Line 666: If String.IsNullOrEmpty(template) Then
Line 667: Return String.Empty
Line 668: End If
Line 669: template = template.Replace("#NAME#", order.FirstName & " " & order.LastName)
Line 670:
Line 671: 'ordernumber
Line 672: template = template.Replace("#ORDERNUMBER#", order.OrderNumber)
Line 673:
Line 674: 'order date
Line 675: template = template.Replace("#ORDERDATE#", order.OrderDate.ToShortDateString())
Line 676:
Line 677: 'now date
Line 678: template = template.Replace("#DATE#", DateTime.Now.ToShortDateString())
Line 679:
Line 680: 'now date
Line 681: template = template.Replace("#TRACKINGNUMBER#", order.ShippingTrackingNumber)
Line 682:
Line 683: ' full order info
Line 684: template = template.Replace("#ORDER#", order.ToHtml())
Line 685:
Line 686: 'tagline
Line 687: template = template.Replace("#TAGLINE#", ConfigurationManager.AppSettings("tagLine"))
Line 688:
Line 689: 'links
Line 690: template = template.Replace("#ADMINPRODUCTLINK#", Utility.GetSiteRoot() & "/admin/admin_orders.aspx?id=" & order.OrderID)
Line 691:
Line 692: template = template.Replace("#SITELINK#", Utility.GetSiteRoot())
Line 693:
Line 694: template = template.Replace("#STOREEMAIL#", "<a href='mailto:" & mailer.FromEmail & "'>" & mailer.FromEmail & "</a>")
Line 695:
Line 696: Return template
Line 697: End Function
Line 698:
Line 699: Public Shared Function getmailinglist(ByVal orderid As Int32) As DataSet
Line 700: 'Return SPs.getmailinglist(orderid).GetDataSet
Line 701: End Function
Line 702: End Class
Line 703:
|