Viruses are programmes, so they have to be triggered, or run.
A text email is a straightforward data file and not a programme, so opening a text message cannot transfer a virus. Similarly, image files such as jpegs and gifs are data files so cannot spread viruses. But macro and file viruses can be sent in attachments to emails or carried in files downloaded from the internet. File viruses can come in any file that can be executed, often EXE or COM files, and are triggered when the programme is opened or run. Macro viruses can be transferred by word processed or spreadsheet files sent as email attachments or downloaded from the internet, but will only infect when these are opened.