Answer
$$y=\frac{e^{x}}{x}+\frac{3-e}{x}$$
Work Step by Step
Given $$x y^{\prime}+y=e^{x}, \quad y(1)=3$$
Then $$ y^{\prime}+\frac{1}{x}y=\frac{1}{x}e^{x} $$
This a linear equation with $p(x) =\frac{1}{x}$ and $q(x) =\frac{1}{x}e^{x} $, so
\begin{align*}
\mu(x) &= e^{\int p(x)dx}\\
&=e^{\int\frac{1}{x} dx}\\
&= e^{\ln x}\\
&=x
\end{align*}
Hence the general solution is
\begin{align*}
\mu(x) y &=\int \mu (x)xq(x)dx\\
x y&=\int \frac{x}{x}e^{x}dx \\
&=\int e^{x}dx\\
&=e^{x}+C
\end{align*}
Then $$ y= \frac{1}{x}e^{x}+C \frac{1}{x}$$
Since $ y(1)= 3 $, then $C= 3-e$, and hence
$$y=\frac{e^{x}}{x}+\frac{3-e}{x}$$