Additional Contact Information

The following example demonstrates how to add additional information, such multiple phone numbers, along with additional job information.


[C#]

static void Main()
{


	//create the email message
	EmailMessage m = new EmailMessage( "127.0.0.1" );
	
	m.FromAddress = "him@hiscompany.com";
	m.To = "you@yourcompany.com";

	m.Subject = "Please see my attached vCard";
	m.Body = "The attached vCard has all of my contact information.";

	vCard vc = LoadvCard();
	m.AddvCard( vc );

	m.Send();
}


public static vCard LoadvCard()
{
	vCard vc = new vCard();

	//set the revision date on the vCard
	vc.Revision.Date = DateTime.Now;

	//set the name information
	vc.Name.FirstName = "Dave";
	vc.Name.LastName = "Jones";

	//set the formatted name
	vc.FormattedName.Value = "David Jones";

	//add a url for work
	vc.Url.UrlAddress = "http://www.hiscompany.com";

	//add organization name
	vc.Organization.Company = "My Example Company";

	//set a role
	vc.Role.Value = "Chemical Industry";

	//set some misc notes
	vc.Note.Value = "The best time to contact me is between 9AM - 5PM EST";

	//set the TimeZone, based upon the offset from GMT.
	//This example will use EST (Est. Standard Time), which is GMT - 5
	vc.TimeZone.TimeZoneValue = new TimeSpan(0, -5, 0, 0 );

	//set the primary address -- which will be a work address in this example
	DeliveryAddress workAddress = new DeliveryAddress( "100 main", "Stevens Point", "WI", "54481", "USA" );
	workAddress.DeliveryAddressType = DeliveryAddressType.WORK;
	vc.DeliveryAddress = workAddress;

	//set the job title
	vc.Title.Value = "Senior Developer";

	//set the primary phone -- which will be a work phone
	vc.Telephone.AddTelephoneType( TelephoneType.WORK );
	vc.Telephone.AddTelephoneType( TelephoneType.VOICE );
	vc.Telephone.Number = "715-555-1212";

	//add a work fax phone
	Telephone faxNumber = new Telephone( "715-555-1313" );
	faxNumber.AddTelephoneType( TelephoneType.WORK );
	faxNumber.AddTelephoneType( TelephoneType.FAX );
	vc.AddProperty( faxNumber );

	//add a cell phone
	Telephone cellNumber = new Telephone( "715-555-1414" );
	cellNumber.AddTelephoneType( TelephoneType.CELL );
	vc.AddProperty( cellNumber );

	//set the email address
	vc.Email.EmailAddress = "daveJones@hiscompany.com";
	vc.Email.Preferred = true;

	//add an additional email address
	Email email2 = new Email( "djones@hiscompany.com", false );
	vc.AddProperty(email2 );
		
	return vc;
}


 

[VB.NET]

Shared Sub Main()
   
   
   'create the email message
   Dim m As New EmailMessage("127.0.0.1")
   
   m.FromAddress = "him@hiscompany.com"
   m.To = "you@yourcompany.com"
   
   m.Subject = "Please see my attached vCard"
   m.Body = "The attached vCard has all of my contact information."
   
   Dim vc As vCard = LoadvCard()
   m.AddvCard(vc)
   
   m.Send()
End Sub 'Main



Public Shared Function LoadvCard() As vCard
   Dim vc As New vCard()
   
   'set the revision date on the vCard
   vc.Revision.Date = DateTime.Now
   
   'set the name information
   vc.Name.FirstName = "Dave"
   vc.Name.LastName = "Jones"
   
   'set the formatted name
   vc.FormattedName.Value = "David Jones"
   
   'add a url for work
   vc.Url.UrlAddress = "http://www.hiscompany.com"
   
   'add organization name
   vc.Organization.Company = "My Example Company"
   
   'set a role
   vc.Role.Value = "Chemical Industry"
   
   'set some misc notes
   vc.Note.Value = "The best time to contact me is between 9AM - 5PM EST"
   
   'set the TimeZone, based upon the offset from GMT.
   'This example will use EST (Est. Standard Time), which is GMT - 5
   vc.TimeZone.TimeZoneValue = New TimeSpan(0, - 5, 0, 0)
   
   'set the primary address -- which will be a work address in this example
   Dim workAddress As New DeliveryAddress("100 main", "Stevens Point", "WI", "54481", "USA")
   workAddress.DeliveryAddressType = DeliveryAddressType.WORK
   vc.DeliveryAddress = workAddress
   
   'set the job title
   vc.Title.Value = "Senior Developer"
   
   'set the primary phone -- which will be a work phone
   vc.Telephone.AddTelephoneType(TelephoneType.WORK)
   vc.Telephone.AddTelephoneType(TelephoneType.VOICE)
   vc.Telephone.Number = "715-555-1212"
   
   'add a work fax phone
   Dim faxNumber As New Telephone("715-555-1313")
   faxNumber.AddTelephoneType(TelephoneType.WORK)
   faxNumber.AddTelephoneType(TelephoneType.FAX)
   vc.AddProperty(faxNumber)
   
   'add a cell phone
   Dim cellNumber As New Telephone("715-555-1414")
   cellNumber.AddTelephoneType(TelephoneType.CELL)
   vc.AddProperty(cellNumber)
   
   'set the email address
   vc.Email.EmailAddress = "daveJones@hiscompany.com"
   vc.Email.Preferred = True
   
   'add an additional email address
   Dim email2 As New Email("djones@hiscompany.com", False)
   vc.AddProperty(email2)
   
   Return vc
End Function 'LoadvCard