Tuesday, July 30, 2019

List of all the Active directory properties:



objectClass=top;person;organizationalPerson;user

cn=x1

sn=LastName

c=PL

l=City

st=State

title=Job title

description=Description

postalCode=Zip

postOfficeBox=POBox

physicalDeliveryOfficeName=Office

telephoneNumber=123456779

givenName=FirstName

distinguishedName=CN=x1,CN=Users,DC=xyz,DC=xyz,DC=xyz

instanceType=4

whenCreated=2012-11-27 21:37:37

whenChanged=2012-12-11 21:33:51

displayName=DisplayName

uSNCreated=System.__ComObject

uSNChanged=System.__ComObject

co=Poland

department=Department

company=Company

streetAddress=Street

name=x1

objectGUID=System.Byte[]

userAccountControl=66048

badPwdCount=0

codePage=0

countryCode=616

badPasswordTime=System.__ComObject

lastLogoff=System.__ComObject

lastLogon=System.__ComObject

pwdLastSet=System.__ComObject

primaryGroupID=513

objectSid=System.Byte[]

accountExpires=System.__ComObject

logonCount=1

sAMAccountName=x1

sAMAccountType=805306368

userPrincipalName=

objectCategory=CN=Person,CN=Schema,CN=Configuration,DC=xyz,DC=xyz,DC=xyz

dSCorePropagationData=1601-01-01 00:00:00

lastLogonTimestamp=System.__ComObject

mail=mail@mail.com

homePhone=1236456654654659

mobile=800800800

   

Monday, July 29, 2019

Send email with images using html template from C#

1. Create Email.html template.




2. Add images in it along with all the necessary placeholders to place values in it. example: ([Receiver]).

 public static void sendMail()
        {
            try
            {
                string recipientMailId = "xyz@abc.com";
                MailMessage Msg = new MailMessage();
                Msg.From = new MailAddress("tcon@somedomain.com", "TEST Console");
                Msg.To.Add(recipientMailId); Msg.Subject = "TEST";
                //Read this html email template                
                string templateToRead = string.Format("{0}\\{1}", HostingEnvironment.MapPath(@"~\EmailTemplates"), "email.html");
                StreamReader reader = new StreamReader(templateToRead);
                string readFile = reader.ReadToEnd();
                reader.Close();
                reader.Dispose();
                string StrContent = readFile;
                //Replace the placeholder  here           
                StrContent = StrContent.Replace("[Receiver]", "AnyName here");
                // Use this string as mail body.               
                string body = StrContent;
                var AltBody = AlternateView.CreateAlternateViewFromString(body, new System.Net.Mime.ContentType("text/html"));
                Msg.AlternateViews.Add(AltBody);
                Msg.IsBodyHtml = true;
                SmtpClient smtp = new SmtpClient("mailo2.dfc.com");
                smtp.Send(Msg);
                smtp.Dispose();
            }
            catch
            {
            } 
}


3. Call above method to Send email.