Click here to Skip to main content
15,920,602 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can I send an email using a distro/group email address?

My code is getting the email address of the user that is currently login on the computer.

What I have tried:

C#
Application oApp = new Application();

        MailItem oMailItem = (MailItem)oApp.CreateItem(OlItemType.olMailItem);
        oMailItem.Recipients.Add(toTxtBox.Text);
        oMailItem.CC = ccTxtBox.Text;
        oMailItem.Subject = sbjTxtBox.Text;

        string x ="";

        string date = Session["date"].ToString();
        string to = Session["to"].ToString();
        string subject = Session["subject"].ToString();             

        oMailItem.HTMLBody = bodyTxtBox.Text + getEmailFile(x);

        if (FileUpload1.HasFile)
        {
            int AttachType = (int)OlAttachmentType.olByValue;
            Attachment Attach = oMailItem.Attachments.Add(FileUpload1.PostedFile.FileName, AttachType, Type.Missing, Type.Missing);
        }

        ((Microsoft.Office.Interop.Outlook._MailItem)oMailItem).Send();
Posted
Updated 29-Mar-16 18:32pm
Comments
an0ther1 29-Mar-16 17:39pm    
Assuming that internal relaying is allowed by your Email server then;

Are you trying to send on behalf of a group email address?
If so the User account that is running the code will need Send As permissions.
If you are trying to send to a Distribution Group then the User account running the code should send to the Group Email address.
If the Distribution Group is an Outlook group (Contact Group versus Exchange Distribution Group) then the User running the code will need the group defined within their Outlook profile

1 solution

Hello,

toTxtBox.Text are add in multiple email id in ";" separated

used following code

string[] addresses = toAddress.Split(";");
foreach (string address in addresses) {
if (!string.IsNullOrEmpty(address)) {
objMessage.To.Add(new MailAddress(address));
}
}


smtp.Send(objMessage);
 
Share this answer
 
Comments
Member 11525563 30-Mar-16 14:58pm    
Need to use the outlook mail item send not the smtp.Sned()

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900