- Unsubscribe
+ string unsubscribeUrl = $"{Request.Scheme}://{Request.Host}/{confirmationPath}?email={user.Email}";
+
+ // This HTML version with proper line breaks works for primary inbox
+ string emailBody = $@"
+
+
+
+
+
+
+
Hej {user.Name},
+
+
+ {viewModel.Body.Replace("\n", "
")}
-
- ";
+
+
Hvis du har spørgsmål, kan du kontakte os på kontakt@nvkn.dk
+
+
+
+
+ ";
var thankYouEmail = new EmailToSend(subscription.Email, subject, body);
await _mailSerivces.SendConfirmationEmailAsync(thankYouEmail);
// Inform the user that the email has been confirmed
- ViewBag.Message = "Thank you for confirming your email. You are now subscribed!";
+ ViewBag.Message = "Tak for at bekræfte din email. Du er nu tilmeldt!";
}
return View(subscription); // You can return a view to show a confirmation message
}
else
{
- ViewBag.Message = "You have been unsubscribed from our newsletter. Thank you!";
- return View(subscription);
+ ViewBag.Message = "Du er blevet afmeldt vores nyhedsbrev. Tak!";
+ return View(subscription);
}
}
catch (Exception ex)
@@ -273,7 +213,6 @@ namespace Web.Controllers
// Log or handle the exception as needed
return View("Error"); // You can return a view to show an error message
}
-
}
[HttpGet]
@@ -296,7 +235,6 @@ namespace Web.Controllers
// Remove the email from SentNewsletterEmail
var sentEmails = _context.SentNewsletterEamils.Where(e => e.RecipientEmail == email);
-
// Set IsUnsubscribed flag to true for email events
foreach (var emailEvent in sentEmails)
{
@@ -307,83 +245,48 @@ namespace Web.Controllers
await _context.SaveChangesAsync();
// Inform the user that the email has been unsubscribed
- ViewBag.Message = "You have successfully unsubscribed from our newsletter. We're sorry to see you go";
+ ViewBag.Message = "Du er nu afmeldt vores nyhedsbrev. Vi er kede af at se dig gå.";
- // Optionally, send an email confirmation to the user
- string subject = "Unsubscription Confirmation";
- string body = $@"
-
-
- Unsubscribe Confirmation
-
-
-
-
-
Unsubscribe Confirmation
-
You have successfully unsubscribed from our newsletter. We're sorry to see you go.
-
- ";
+ // Send a simple confirmation email to the user
+ string subject = "Bekræftelse på afmelding";
- var thankYouEmail = new EmailToSend(subscription.Email, subject, body);
- await _mailSerivces.SendConfirmationEmailAsync(thankYouEmail);
+ // Simple plain text email body
+ string body = $@"Hej,
- return View(subscription); // You can return a view to show a confirmation message
+ Du er nu afmeldt vores nyhedsbrev.
+
+ Med venlig hilsen,
+ Nærværskonsulenterne ApS
+
+
+
+ Nærværskonsulenterne ApS
+ Brødemosevej 24A, 3300 Frederiksværk
+ kontakt@nvkn.dk";
+
+ var confirmationEmail = new EmailToSend(subscription.Email, subject, body);
+ await _mailSerivces.SendConfirmationEmailAsync(confirmationEmail);
+
+ return View(subscription);
}
else
{
// If IsSubscribed is already false, inform the user that the email is already unsubscribed
- ViewBag.Message = "Your email is already unsubscribed. Thank you!";
- return View(subscription); // You can return a view to show a message
+ ViewBag.Message = "Din email er allerede afmeldt. Tak!";
+ return View(subscription);
}
}
else
{
// Inform the user that the unsubscription process couldn't be completed
- ViewBag.Message = "You have been unsubscribed from our newsletter. subscribe first.";
- return View(subscription); // You can return a view to show an error message
+ ViewBag.Message = "Du er blevet afmeldt vores nyhedsbrev. Tilmeld dig først.";
+ return View(subscription);
}
}
catch (Exception ex)
{
// Log or handle the exception as needed
- return View("Error"); // You can return a view to show an error message
+ return View("Error");
}
}