locked
sending atatchment in multiple mail ids. RRS feed

  • Question

  •  

    Hi all,

     

    I have written code for sending mail for two email ids,everthing is working fine but attachment is not going for second mail id.

     

     

    int count=0;

    for(count=0;count<obj_email.to.Length ;count++)

    {

    // retrieve contactid from to field of contact

    activityparty objActivityParty;

    objActivityParty = (activityparty)obj_email.to.GetValue(count) ;

    contact obj_contact1=new contact();

    //retrieve contact for swapping of emailaddress1 with emailaddress2

    ColumnSet contact_cols1=new ColumnSet();

    contact_cols1.Attributes=new string[]{"emailaddress1","address1_telephone1"};

    obj_contact1=(contact)service.Retrieve(EntityName.contact.ToString(),objActivityParty.partyid.Value,contact_cols1);

    //update after swapping the emails first time

    contact obj_con_update_first=new contact();

    obj_con_update_first.emailaddress1=obj_contact1.address1_telephone1;

    obj_con_update_first.address1_telephone1=obj_contact1.emailaddress1;

    Key obj_update_first=new Key();

    obj_update_first.Value=objActivityParty.partyid.Value;

    obj_con_update_first.contactid=obj_update_first;

    service.Update(obj_con_update_first);

    // send mail to secondary email address after swapping

    email obj_emailsend=new email();

    activityparty obj_aparty_to=new activityparty();

    obj_aparty_to.partyid=new Lookup();

    obj_aparty_to.partyid.type=EntityName.contact.ToString();

    obj_aparty_to.partyid.Value=objActivityParty.partyid.Value;

    //create new attachment object

    activitymimeattachment obj_attachment=new activitymimeattachment();

    obj_attachment.activityid=new Lookup();

    obj_attachment.activityid.type=emailid.ToString();

    obj_attachment.activityid.Value=objActivityParty.activityid.Value;

     

    // This is the first attachment.

    //

    // obj_attachment.attachmentnumber=new CrmNumber();

    // obj_attachment.attachmentnumber.Value=1;

    // Guid attachmentId = myCRMService.Create(obj_attachment);

    //

     

    obj_emailsend.to=new activityparty[]{obj_aparty_to};

    obj_emailsend.torecipients=obj_email.torecipients;

    activityparty obj_aparty=new activityparty();

    obj_aparty=(activityparty)obj_email.from.GetValue(count);

    activityparty obj_aparty_from=new activityparty();

    obj_aparty_from.partyid=new Lookup();

    obj_aparty_from.partyid.type=EntityName.systemuser.ToString();

    obj_aparty_from.partyid.Value=obj_aparty.partyid.Value;

    obj_emailsend.from=new activityparty[]{obj_aparty_from};

    obj_emailsend.prioritycode=new Picklist();

    obj_emailsend.prioritycode.Value=obj_email.prioritycode.Value;

    obj_emailsend.description=obj_email.description;

    obj_emailsend.subject=obj_email.subject;

    }

     

    subject and description are passing to second mail id,only attachment is not going.

    how to write the code for sending attachment for second mail id?

     

    Thank u.

    Friday, January 9, 2009 10:47 AM

All replies

  • use CC , BBC addresses with , (comma)

     

    Regards,

    Imran

     

     

    Thursday, January 15, 2009 12:15 PM
    Moderator