aspNetEmail

EmailMessage.AddvCard Method 

Adds a vCard to the EmailMessage object.

public void AddvCard(
   vCard vCard
);

Parameters

vCard
vCard object.

Example

[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 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 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;
             
                //add an additional home address
                DeliveryAddress homeAddress = new DeliveryAddress( "100 Peachtree Ln", "Stevens Point", "WI", "54481", "USA" );
                homeAddress.DeliveryAddressType = DeliveryAddressType.HOME;
                vc.AddProperty( homeAddress );
             
             
                //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;
            }
                
[Visual Basic]
            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 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 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
               
               'add an additional home address
               Dim homeAddress As New DeliveryAddress("100 Peachtree Ln", "Stevens Point", "WI", "54481", "USA")
               homeAddress.DeliveryAddressType = DeliveryAddressType.HOME
               vc.AddProperty(homeAddress)
               
               
               '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
                

See Also

EmailMessage Class | aspNetEmail Namespace