@@ -61,23 +61,43 @@ public static List<GeneralEmailResponse> Parse(IEnumerable<string> responses)
6161 {
6262 var responseList = new List < GeneralEmailResponse > ( ) ;
6363
64- foreach ( var match in responses . Select ( response => Regex . Match ( response , GmailPattern ) ) )
64+ foreach ( var response in responses )
6565 {
66- // Check if the response string matches the expected format
67- if ( ! match . Success || match . Groups . Count != 6 )
66+ var match = Regex . Match ( response , GmailPattern ) ;
67+
68+ if ( ! match . Success )
6869 {
69- throw new ArgumentException ( "Invalid response string format." ) ;
70+ match = Regex . Match ( response , OutlookPattern ) ;
71+
72+ if ( ! match . Success )
73+ {
74+ throw new ArgumentException ( "Invalid response string format." ) ;
75+ }
7076 }
7177
72- // Create a new instance of EmailSendResponse and populate its properties
73- responseList . Add ( new GeneralEmailResponse
78+ if ( match . Groups . Count == 5 )
7479 {
75- Status = match . Groups [ 1 ] . Value ,
76- Code = match . Groups [ 2 ] . Value ,
77- TrackingId = match . Groups [ 3 ] . Value ,
78- Id = match . Groups [ 4 ] . Value ,
79- Service = match . Groups [ 5 ] . Value
80- } ) ;
80+ responseList . Add ( new GeneralEmailResponse
81+ {
82+ Status = match . Groups [ 1 ] . Value ,
83+ Code = match . Groups [ 2 ] . Value ,
84+ TrackingId = null ,
85+ Id = match . Groups [ 3 ] . Value ,
86+ Service = match . Groups [ 4 ] . Value
87+ } ) ;
88+ }
89+
90+ if ( match . Groups . Count == 6 )
91+ {
92+ responseList . Add ( new GeneralEmailResponse
93+ {
94+ Status = match . Groups [ 1 ] . Value ,
95+ Code = match . Groups [ 2 ] . Value ,
96+ TrackingId = match . Groups [ 3 ] . Value ,
97+ Id = match . Groups [ 4 ] . Value ,
98+ Service = match . Groups [ 5 ] . Value
99+ } ) ;
100+ }
81101 }
82102
83103 return responseList ;
0 commit comments