How to fix the SMTP address has no mailboxes associated with it error in .net dll

Lakshmi0766 0 Reputation points
2024-03-11T14:43:46.6466667+00:00

We are using a .net dll to read an outlook emails using exchnager url and the version. It was working fine untill couple of days ago then I started to get failed to extract mail id from outlook - the stmp address has no mailboxes with it.

Ther version is Exchange2013_Sp1 ( in the line findfolderResults the STMP error is getting)

The below codes are using to read:

public static string GetEmailUniqueIdAndCategory(string userName, string password, string emailAddress, string domain, string exchangeURL, string exchangeVersion, string strOutlookSubFolderName, string strOutlookDestFolderName, string strCategoryName)

    {

        var str = "";

        try

        {

            //View size

            int pageSize = 200;

            int offset = 0;

            //bool more = true;

            List<string> lstMailEntryId = new List<String>();               

            ExchangeService service = GetExchangeService(userName, password, emailAddress, domain, exchangeURL, exchangeVersion);               

            ItemView ItemView = new ItemView(pageSize, offset);

            PropertySet properties = new PropertySet(BasePropertySet.FirstClassProperties);

            properties.RequestedBodyType = BodyType.HTML;

            ItemView.PropertySet = properties;

            FindItemsResults<Item> findResults;

            FolderView view = new FolderView(100);

            view.PropertySet = new PropertySet(BasePropertySet.IdOnly);

            view.PropertySet.Add(FolderSchema.DisplayName);

            view.Traversal = FolderTraversal.Deep;

            FindFoldersResults findFolderResults = service.FindFolders(WellKnownFolderName.MsgFolderRoot, view);

            // find specific folder

            foreach (Folder folder in findFolderResults)

            {

                // show FolderId of the folder "eAOB"

                if (folder.DisplayName == strOutlookSubFolderName)

                {

                    findResults = service.FindItems(folder.Id, ItemView);

                    var result = findResults.OrderBy(Item => Item.DateTimeReceived).ToList();

                    //foreach (var item in findResults)

                    foreach (var item in result)

                    {

                        EmailMessage emailMessage = (EmailMessage)item;

                        item.Load(properties);

                        bool subjectContains = Regex.IsMatch(item.Subject, "Mail Delivery Subsystem", RegexOptions.IgnoreCase);

                        bool bodyContains = Regex.IsMatch(item.Subject, "UnDeliverable", RegexOptions.IgnoreCase);

                        if (subjectContains || bodyContains)

                        {

                            FindFoldersResults finsSubFoldersResults = service.FindFolders(folder.Id, view);

                            foreach (Folder subFolder in finsSubFoldersResults)

                            {

                                if (subFolder.DisplayName == strOutlookDestFolderName)

                                {

                                    // Move Undelivered mail to destination subfolder

                                    item.Move(subFolder.Id);

                                }

                            }

                        }

                        else

                        {

                            //Categorizing the Mail

                            StringList existingCategories = item.Categories;                                

                            if (existingCategories.Count == 0)

                            {

                                item.Categories.Add(strCategoryName);

                                //Retrieving unread mail Unique Id's and mark the mail as read

                                str += item.Id + "~";

                                emailMessage.IsRead = true;

                                emailMessage.Update(ConflictResolutionMode.AutoResolve);

                            }                               

                        }

                    }

                }

            }

            return str.Trim('~');

        }

        catch (Exception ex)

        {

            return "Exception : " + ex.Message;

        }

    }
```Help this issue to resolve as soon as possible
Exchange Server
Exchange Server
A family of Microsoft client/server messaging and collaboration software.
1,091 questions
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,412 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,300 questions
Exchange Server Development
Exchange Server Development
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Development: The process of researching, productizing, and refining new or existing technologies.
515 questions
{count} votes