Matthew Rodwell

Matthew Rodwell

  • NA
  • 46
  • 1.3k

String not working in main part

Aug 13 2020 8:11 AM
In the script below i am working out hte correct email address to send something too. but the srEmail isn't populating in the final part. i think i have set the code up wrongly as it like they don't see each other. I get an error saying it doesn't exist in this content but how do i get round that
 
thanks
  1. String myOffice = dirEntry.Properties["physicalDeliveryOfficeName"].Value.ToString();  
  2. if (myOffice == "Leeds")  
  3. {  
  4. String srEmail = "[email protected]";  
  5. }  
  6. else if (myOffice=="Sheffield")  
  7. {  
  8. String srEmail = "[email protected]";  
  9. }  
  10. else if (myOffice =="York")  
  11. {  
  12. String srEmail = "[email protected]";  
  13. }  
  14. String Date = DateTime.Now.ToShortDateString();  
  15. Outlook.Application app = new Outlook.Application();  
  16. Outlook.MailItem mailItem = app.CreateItem(Outlook.OlItemType.olMailItem);  
  17. mailItem.Subject = "New Stationary Order - " + myName + ":" + Date;  
  18. mailItem.To = srEmail;  
  19. string htmlString = @"<html>  

Answers (4)